Created by Kevin Culkins, last modified by Robert Nelson on Sep 08, 2017
Introduction
The Microchip PIC24 is a 16-bit microcontroller that integrates a high-performance graphics controller capable of driving QVGA (320x240) or WQVGA (up to 480x272) color LCD display touch panels that are controllerless, USB OTG modules, as well as a broad range of peripherals. Example hardware and software has been developed by Microchip to demonstrate the PIC24s graphics capability. The PIC24 used in the PIC24FJ256DA210 Development Board have sufficient internal RAM (96Kbytes) to support graphics with 8 BPP (bit per pixel) color depth and with an external RAM device up to 16 BPP is possible. With relatively minor source code revisions and a custom interface board, this project leverages the Microchip developed hardware and software to interface a Newhaven Display International 3.5" QVGA color LCD display touch panel to a PIC24.
Background
Newhaven Display International offers a readily available 3.5" color LCD with touch screen, sans controller. A combination of a Microchip demonstration board, the Newhaven LCD, and a custom interface board constitute a complete display demonstration project.
Application
The demonstration software shows the capabilities of the PIC24 driving (16 BPP color depth) a Newhaven Display International controllerless LCD graphics board. The start up splash screen is a bitmap image. The subsequent screens demonstrate the widgets of the Microchip Graphics Library to show various application screens that can be easily made with the library. Also, Microchip makes available a visual design tool to create your own graphical user interface screens for Microchip microcontrollers, the Graphics Display Designer (GDD).
Hardware Requirements
A PIC24FJ256DA210 Development Board, ICD3 (or REAL ICE or PICkit3), Newhaven display and custom interface board (figure 1, below) is required.
PIC24FJ256DA210 Development Board, DM240312.
MPLAB® ICD3 In-Circuit Debugger, or REAL ICE™, or PICkit™ 3
DKSB1014B-ND is now available from DigiKey, uniting display NHD-3.5-320240MF-ATXL#-T-1-ND with interface adapter board NHD-3.5-320240MF-PICADAPTER-ND.
Fig. 1
Settings
The PIC24FJ256DA210 Development Board provides numerous jumpers for various board configurations. For this demonstration, the jumpers are positioned per Table 1. Additional information is available in the PIC24FJ256DA210 Development Board User’s Guide.
Jumper | Function | Jumper Setting |
---|---|---|
JP5 | Enables USB OTG | Remove jumper |
JP6 | Enables USB Embedded Host mode | Install jumper |
JP7 | Enables USB Device mode | Remove jumper |
JP8 | Sets Byte Enable mode for on-board parallel memory | Remove jumper |
JP9 | Configures RA1 and RC4 for resistive touch screen or SPI-based touch controller | Jumper 1 - 2 |
JP10 | Configures RA1 and RC4 for resistive touch screen or SPI-based touch controller | Jumper 1 - 2 |
JP11 | Selects RA7 for LED D4 or PMA17 | Jumper 1 - 2 |
JP12 | Configures RD0 for LCD backlight control or serial RX | Jumper 1 - 2 |
JP13 | Configures RG8 as S1 input or CTMU1 input/LED output | Jumper RG8 - S1 |
JP14 | Configures RE9 as S2 input or CTMU2 input/LED output | Jumper RE9 - S2 |
JP15 | Configures RB5 as S3 input, R3 input, or CTMU3 input/LED output | Jumper RB5 - S3 |
JP16 | Selects serial TX channel connection | Jumper USART_TX - TX |
JP17 | Selects serial RX channel connection | Jumper USART_RX – RX |
JP23 | Selects serial (default) or parallel Flash memory | Jumper 2 - 3 |
Table 1. Jumper Settings and Configuration Options
Software Requirements
The Microchip Libraries for Applications (MLA) includes a broad range of software libraries. Projects are provided that support many Microchip development and evaluation boards. The demonstration software referenced in this eewiki article leverages the “Multi-App” project files to drive the display and also support the USB Mass Storage Device class, allowing the viewing of stored graphic files from a Flash stick. Only one new and one revised file are required to successfully drive the Newhaven 3.5” QVGA display.
New source file supporting Newhaven 3.5" display is: HWP_DA210_BRD_16PMP_USBMSD_NHD_QVGAv1.h
Revised source file supporting Newhaven 3.5" display is: HardwareProfile.h
Complete project Multi-App_NHD_QVGA.zip (4.8 MB) includes a single project configuration and relevant source files that were provided in the original “Multi-App” folder (note: this is an MPLAB X project). The multiple project configurations and configuration files not necessary in this build have been removed to reduce the zip file size. Of course, these omitted files are available in the “Multi-App” folder that is included in the MLA download.
Source file and code changes:
HardwareProfile.h
Several lines of code are added to the HardwareProfile.h file to support the Newhaven display. The code snippet below will include the header file that defines the use of the Newhaven display.
/*********************************************************************
* Hardware Configuration for
* DA210 Developement board
* 16-bit PMP
* QVGA, Newhaven 3.5" display
* USB MSD
********************************************************************/
#elif defined(CFG_INCLUDE_DA210_BRD_16PMP_USBMSD_QVGAv1_NHD)
#include "Configs/HWP_DA210_BRD_16PMP_USBMSD_NHD_QVGAv1.h"
//#elif defined(CFG_INCLUDE_DA210_BRD_16PMP_USBMSD_WQVGAv1)
HWP_DA210_BRD_16PMP_USBMSD_NHD_QVGAv1.h
Define the use of Newhaven LCD panel
#define GFX_USE_DISPLAY_PANEL_TFT_NHD_320240MF_ATXL_T_1
Define the LCD glass characteristics.
#if defined (GFX_USE_DISPLAY_PANEL_TFT_NHD_320240MF_ATXL_T_1)
#define DISP_ORIENTATION 0
#define DISP_HOR_RESOLUTION 320
#define DISP_VER_RESOLUTION 240
#define DISP_DATA_WIDTH 24
#define DISP_INV_LSHIFT
#define DISP_HOR_PULSE_WIDTH 30
#define DISP_HOR_BACK_PORCH 40
#define DISP_HOR_FRONT_PORCH 20
#define DISP_VER_PULSE_WIDTH 4
#define DISP_VER_BACK_PORCH 9
#define DISP_VER_FRONT_PORCH 1
#define GFX_LCD_TYPE GFX_LCD_TFT
#if defined(GFX_USE_DISPLAY_CONTROLLER_MCHP_DA210)
#define GFX_DISPLAYENABLE_ENABLE
#define GFX_HSYNC_ENABLE
#define GFX_VSYNC_ENABLE
// #define GFX_DISPLAYPOWER_ENABLE
#define GFX_CLOCK_POLARITY GFX_ACTIVE_HIGH
#define GFX_DISPLAYENABLE_POLARITY GFX_ACTIVE_HIGH
#define GFX_HSYNC_POLARITY GFX_ACTIVE_LOW
#define GFX_VSYNC_POLARITY GFX_ACTIVE_LOW
#endif
#endif // #if defined (GFX_USE_DISPLAY_PANEL_TFT_NHD_320240MF_ATXL_T_1)
Define the backlight control logic.
#elif defined (GFX_USE_DISPLAY_PANEL_TFT_NHD_320240MF_ATXL_T_1)
#define BACKLIGHT_ENABLE_LEVEL 1
#define BACKLIGHT_DISABLE_LEVEL 0
#else
Project Build and Load
It is left to the reader to install and familiarize themselves with MPLAB X IDE, the XC16 compiler, and hardware connections from/to the PIC24 development kit.
The project requires supporting files that are included in the “Microchip Libraries for Applications v2013-06-15” (MLA).
Microchip does revise and release updated versions of the MLA. If the aforementioned MLA is no longer found check the MLA archive, or follow this link to the archive.
Download and install the MLA files. After download and installation of the MLA files download the project zip file Multi-App_NHD_QVGA.zip (4.8 MB) . Expand the zip file and copy the folder “Multi-App_NHD_QVGA” to the “Microchip_solutions_v2013-06-15\Graphics” folder.
Open MPLAB X IDE, connect the hardware to your computer, select “Open Project”. Assuming that the MLA is installed in its default location, navigate to folder “Microchip_solutions_v2013-06-15\Graphics\Multi-App_NHD_QVGA” and select project “MPLAB.X”. Open the project properties to verify hardware and software tool selection matches your installation. Make and Program device.
Hex file is available in folder "…\Multi-App_NHD_QVGA\Precompiled Hex”, title “Graphics – Multi-App PIC24_DA210_DEV_16PMP_QVGAv1_USBMSD_NHD.hex.
Supporting Files
Software
Multi-App_NHD_QVGA.zip (see above link)
Schematic
DKSB1014B.pdf (30.3 KB)
BOM
DKSB1014B_BOM.xls (29.5 KB)
Gerber Files
DKSB1014B_gerber_drill.zip (36.4 KB)
OrCAD 16.3 Capture and PCB Editor Project Files
DKSB1014B_project_files.zip (244.4 KB)
Application Notes
PIC24FJ256DA210 Development Board User’s Guide. The document provides an introduction to the development board, development board hardware description, and schematics.
AN1368 “Developing Embedded Graphics Applications using PIC(r) Microcontrollers with Integrated Graphics Controller”. This application note delves into using PIC devices with an integrated graphics controller, but it also provides background information on basic color science, display terminology, display power sequencing, and resistive touch screens.
Questions/Comments
Any questions or comments please go to DigiKey’s TechForum