This page is about interfacing a Newhaven Display International QVGA 3.5" color LCD display touch panel to a Microchip Technology PIC32 and Panasonic BLE module.
Introduction
The Microchip PIC32 has the bandwidth to drive QVGA (320x240) or WQVGA (up to 480x272) color LCD display touch panels that are controllerless - all LCD drive requirements are met by the PIC32. Example hardware and software has been developed by Microchip to demonstrate the PIC32s graphics capability. The PIC32 used in the starter kits have sufficient internal RAM (128Kbytes) to support graphics with 8 BPP (bit per pixel) color depth and with an external RAM device 16 BPP is possible.
This project uses Microchip’s MPLABX IDE and MPLAB Harmony Integrated Software Framework for development of the application and graphics objects. Files are provided that make the Newhaven Display International 3.5” QVGA color LCD display touch panel available in the MPLAB Harmony Framework. The sensor suite provides temperature, humidity, and pressure, with all sensor data presented on the display. Communication between the PIC32 and the BLE module is over SPI bus.
Background
Newhaven Display International offers a readily available 3.5" color LCD with touch screen, sans controller. A combination of existing Microchip demonstration boards, the Newhaven LCD and a custom interface board constitute the demonstration project. The sensor suite module is optional, but if omitted, no real time data will be available.
Application
The demonstration software shows the capabilities of the PIC32 driving a Newhaven Display International controllerless LCD graphics board while gathering and displaying temperature, humidity, pressure, and dewpoint data. All of the graphical user interface screens, widgets, and primitives are generated using the Graphics Composer component of the Harmony Framework greatly reducing the effort required. A single bitmap image is used for the main screen, as well as secondary display screens. The LCC (Low-Cost Controllerless) Daughterboard can support QVGA, WQVGA, and VGA (with the addition of larger external SRAM) resolutions and anything lower.
Hardware Requirements
Various hardware combinations can be used to drive the LCD display, but this Harmony project only supports the PIC32 USB Starter Kit II. At minimum, a PIC32USB Starter Kit II (DM320003-2-ND) is required, along with an LCC Graphics PICtail™ Daughter Board, (AC164144-ND) a PCB mounted Newhaven display with resistive touch (DKSB1014B-ND) (figure 1). For real time temperature, humidity, pressure, and dewpoint information display, the aforementioned BLE module will have to be constructed. Optionally, for I/O accessibility, a PIC32 I/O Expansion Board (DM320002-ND) can be connected to the Graphics PICtail™ Plus Daughter Board (figure 2).
Figure 1.
Figure 2.
Settings
The PICtail Plus board provides a row of header pins with jumpers (schematic in AN1387). The jumpers are positioned to use internal memory (memory residing in the PIC32 device) or external memory residing on the PICtail Plus Daughter board, and the color depth 8 BPP or 16 BPP. The desired memory use and color depth in software and hardware must match. If there is a mismatch between the software selection and hardware selection images will not display properly.
To use internal memory and 8 BPP color depth all jumpers on the LCC Graphics PICtail Plus Daughterboard must be installed across rows 1 and 2 (figure 3) and for external memory and 16 BPP install all jumpers across rows 2 and 3 (figure 4). This demonstration requires the jumpers positioned for external memory and 16 BPP color.
Figure 3.
Figure 4.
Software Requirements
Application Brief
The application is developed using MPLAB X IDE and MPLAB Harmony Configurator (MHC). Screens, icons, and widgets are bit map images that are imported using the Graphics Composer component of MHC. Using MHC greatly reduces the level of effort to generate peripheral configuration and initialization code. Yes, there is a learning curve, but this is time well spent that will reduce development time on future projects.
The application itself is relatively simple and is contained in two files sensordisply.c and sensordisplay.h within the project zip file linked below. Hardware initialization of the SPI peripheral and display resources is completed with no developer generated code, since it’s been generated by MHC. Several callback functions need to be created by the developer, as well as declaring variables and buffers used in the application code. Program flow is driven by a state-machine. SPI communication with the client BLE module occurs periodically to read sensor data and update the data displayed. The screen is driven and refreshed without any main-loop code.
Application Development Notes
At the start of development there were issues with screen switching that weren’t seamless, with blanking occurring between each screen change. This occurred because double buffering wasn’t enabled. Double buffering makes screen rendering appear seamless because there are two memory buffers, the screen buffer and the draw buffer. Changes to the screen are made in the draw buffer and when complete the screen buffer pointer is swapped with the draw buffer. AN1368, Appendix B provides a detailed explanation.
Double buffer is already enabled in this project. For a new project, the feature is selected in MHC by navigating down the MHC configuration hierarchy by expanding “Harmony Framework Configuration”, “Graphics Library”, ”Use Graphics Library”, “Use Special Effects”, and checking “Enable Double Buffering” (figure 5). The GFX_DoubleBufferEnable function needs to be called by the user source code. Details on double buffer enable and all of the graphics library functionality is provided in MPLAB Harmony Graphics Libraries Help document.
Figure 5.
Font primitives are used to update the main menu sensor data display. Primitive functions are blocking and disable some events when the primitive function is executed ( MPLAB Harmony Graphics Libraries Help , Configuration Example 2 lists disabled items). Due to time constraints and unfamiliarity with using text objects to get clean screen updates, the decision was made to use text primitive functions to update the sensor data. They do work, but on occasion the user may notice that the touch screen doesn’t respond as quickly. This is due to the primitive function temporarily disabling the touch screen. Presumably, using text objects would remove this issue.
Project Build and Load
It is left to the reader to install and familiarize themselves with MPLAB X IDE, MPLAB Harmony Integrated Software Framework, the XC32 compiler, and hardware connections from/to the PIC32 starter kit of choice.
The project can be built (or source files can be modified) without opening MHC, but if you wish to view (or change) the configuration options that include the Newhaven display, and select MHC to generate code, then two files will need to be replaced, and a new folder and files will need to be placed in the MHC installation.
These revised files are compatible with MPLAB Harmony Integrated Software Framework version v1.6.xx, and contain paths to the Newhaven display MHC configuration file and FreeMarker template file.
Expand the “gfx_displays_from_digikey.zip” file containing the revised files and new folder. Make a backup of “third_party.hconfig” located in “\ third_party\config”, then replace with copy from the zip file. Make a backup of “system_config.h.ftl” located in “\ utilities\mhc\templates\app\system_config”, then replace with copy from the zip file.
Copy the new folder, “gfx_displays_from_digikey" from the zip file and paste to “\ third_party”. This folder contains two sub-folders, “config” and “templates”. “Config” sub-folder contains the MHC file “drv_gfx_display_dk.hconfig”, while “Templates” sub-folder contains “drv_gfx_display_dk.h.ftl”.
Expand/copy zip file “SensorDemoProject.zip” to desired system location. Open MPLAB X IDE, connect the hardware to your computer, and open project “SensorDemoProject”. Open the project properties to verify hardware and software tool selection matches your installation. Make and Program device.
To explore the Harmony Configurator menu, make the “SensorDemoProject” the Main Project in MPLAB X IDE and start the MPLAB Harmony Configurator. Cancel out of the prompt to open the default.mhc configuration, and instead, open configuration at “\SensorDemoProject\firmware\src\system_config\default\pic32mx_usb_sk2_lcc_pictail_qvga_NHD.mhc”.
In the event that changes are made to the configuration that “breaks” the build, a backup of the configuration file is available in the same folder. Filename is “backup_pic32mx_usb_sk2_lcc_pictail_qvga_NHD.mhc”.
The Newhaven display configuration settings can be found in the “Third Party Libraries” section, “Graphics Displays From Digikey” (figure 6), not in the “Harmony Framework Configuration”, ”Drivers”, “Graphics Displays” section (figure 7).
Figure 6.
Figure 7.
Supporting Files
Software
SensorDemoProject.zip (2.2 MB)
gfx_displays_from_digikey.zip (6.0 KB)
Display Schematic, BOM, Gerber Files
DKSB1014B.pdf (30.3 KB)
DKSB1014B_BOM.xls (29.5 KB)
DKSB1014B_gerber_drill.zip (36.4 KB)
Application Notes
AN1387 “Using PIC32 MCU’s to Develop Low-Cost Controllerless (LCC) Graphics Solutions”.
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, double buffering, and resistive touch screens.