Search:

Description | Hardware | Files | Library | Examples | Parallell Master Port | References

Multiline LCD display driver for the Microchip PIC32 family of microcontrollers

This driver provides support for terminal output to the Electronic Assembly DOG-M family of LCD displays, interfacing microcontrollers of the Microchip PIC32 family. The driver supports full ASCII functionality such as carriage return, backspace commands, line wrapping and arbitrary positioning of character output within the display, employing the Parallel Master Port (PMP) of the PIC32.

The PIC32 development board with LCD display

Description of the driver

The set of routines in dogm16x.c provides a driver for the Electronic Assembly DOG-M family of LCD displays [1, 2] for the Microchip PIC32 microcontroller, employing the Parallel Master Port (PMP) [3], with data on pins PMD0-PMD7 and PMP control signals on pins PMWR, PMRD and PMA0.

Hardware connections

The connections between the Parallel Master Port [3] (PMP, data on pins PMD0-PMD7; PMP control signals on pins PMWR, PMRD, and PMA0) of the PIC32MX processor and the Electronic Assembly DOGM display are as follows:


    PIC32 pin      OLIMEX PCB     LCD pin
--------------------------------------------------------------------------
    PMD7    ---    RE7     ---    28 (D7)         Display data, MSB
    PMD6    ---    RE6     ---    29 (D6)         Display data
    PMD5    ---    RE5     ---    30 (D5)         Display data
    PMD4    ---    RE4     ---    31 (D4)         Display data
    PMD3    ---    RE3     ---    32 (D3)         Display data
    PMD2    ---    RE2     ---    33 (D2)         Display data
    PMD1    ---    RE1     ---    34 (D1)         Display data
    PMD0    ---    RE0     ---    35 (D0)         Display data, LSB
    PMWR    ---    RD4     ---    36 (E)          Enable, falling edge
    PMRD    ---    RD5     ---    37 (R/W)        Low=Write, High=Read
    PMA0    ---    RB15    ---    39 (RS)         Low=Control, High=Data

In addition, the following connections to the LCD provide power supply and proper ground:


    PIC32 pin     OLIMEX PCB    LCD pin
                  GROUND --- 38 (CSB)        Chip select
                  GROUND --- 27 (VSS)        Power supply, 0V
                  +3.3V  --- 26 (VDD)        Power supply, +3.3V
                  +3.3V  --- 25 (VIN)
                  +3.3V  --- 23 (PSB)
                  +3.3V  --- 40 (RESET)
                  +3.3V  --- X ohm resistor --- 20   Power supply 3.3V, illumination
                  +3.3V  --- X ohm resistor --- 1    Power supply 3.3V, illumination
                  GROUND --- 2 (VSS)         Power supply 0V, illumination
                  GROUND --- 19 (VSS)         Power supply 0V, illumination
                |------------   21 (CAP1N)
               === 2.2 uF Capacitor
                |------------   22 (CAP1P)
                |------------  24 (VOUT)
               === 2.2 uF
   +3.3V -------|

Files

dogm16x.c [23 kB] ANSI-C (ISO C90) conforming source code for the Electronic Assembly DOG-M display driver.
[ download | view source ]

dogm16x.h [5 kB] ANSI-C (ISO C90) conforming header file for the Electronic Assembly DOG-M display driver.
[ download | view source ]

main.c [1 kB] The main() routine here merely illustrates the usage of the dogm16x display driver. See dogm16x.c for details on the driver routines.
[ download | view source ]

Makefile_hex [853 bytes] The Makefile for compilation of the hex image illustrating usage of the driver (see main.c). To compile the hex image, simply run 'make -f Makefile_hex' in the directory containing the source files and this Makefile.
[ download | view source ]

Makefile_lib [641 bytes] The Makefile for compilation of the shared library containing the driver. To compile the library, simply run 'make -f Makefile_lib' in the directory containing the source files and this Makefile.
[ download | view source ]

libdogm16x.a [(No file available)] Shared library containing the driver for the Electronic Assembly DOG-M LCD display.
[ download ]

Installing the driver as a shared library

See separate document on Using shared libraries in other projects.

Examples of usage

Example 1. High-level usage of the library, writing entire strings of data:


   char buf[128];
   float x=0.4711;
   write_string_to_display("Hello World!\n");
   sprintf(buf,"sin(%f)=%f\n",x,sin(x));
   write_string_to_display(buf);

Example 2. Low-level usage of the library, writing individual characters and positioning the cursor by direct access to the LCD registers:


   /* Set position to 1st row, 1st col */
   write_to_display_register(LCDCMD,0x80|0x00);

   /* Write 'A' at 1st row, 1st col */
   write_to_display_register(LCDDATA,'A');

   /* Reposition to 1st row, 1st col */
   write_to_display_register(LCDCMD,0x80|0x00);

   /* Overwrites the previous 'A' */
   write_to_display_register(LCDDATA,'B');

   /* Writes a 'C' next after the 'B' */
   write_to_display_register(LCDDATA,'C');

   /* Reposition to 1st row, 6th col */
   write_to_display_register(LCDCMD,0x80|0x05);

   /* Writes a 'C' at 1st row, 5th col */
   write_to_display_register(LCDDATA,'D');

   /* Writes a 'E' next after the 'D' */
   write_to_display_register(LCDDATA,'E');

   /* Set position to 2nd row, 1st col */
   write_to_display_register(LCDCMD,0x80|0x10);

   /* Write 'G' at 1st row, 1st col */
   write_to_display_register(LCDDATA,'G');
   sprintf(buf,"%d",read_display_register(0x02)&0x7f);
   write_string_to_display(buf);

Example 3. Example of usage of the driver, from main.c:


/*=====================================================================
 * File:        main.c
 * Summary:     The main() routine here merely illustrates the usage
 *              of the dogm16x display driver for the Microchip PIC32
 *              family of microcontrollers. See dogm16x.c for details
 *              on the driver routines.
 * Created:     September 12, 2010 [v.1.0]
 * Last change: September 12, 2010 [v.1.0]
 * Author:      Fredrik Jonsson <http://jonsson.eu/>
 *
 * Copyright (C) 2010, Fredrik Jonsson <http://jonsson.eu/>
 * Non-commercial copying welcome.
 *===================================================================*/
#include <stdio.h>   /* To access sprintf() in the driver example */
#include <math.h>    /* To access sin() in the driver example     */
#include "dogm16x.h"

int main(void)
{
   char buf[128];
   float x=0.4711;

   initialize_display();
   clear_display();
   write_string_to_display("Hello World!\n");  /* 1st row of display */
   sprintf(buf,"sin(%f)=%f\n",x,sin(x));
   write_string_to_display(buf);               /* 2nd row of display */
   while(1);                                   /* Infinite loop      */
}

This example simply provides the following output, illustrating the automatic wrap-around of the text displayed in the second line (as this is more than 16 characters long):

Output from example of usage of LCD driver, as listed in main.c

About the Parallell Master Port (PMP) of the PIC32 microcontroller

Directly from the PIC32 Family Reference Manual [3]: "The Parallel Master Port (PMP) is a parallel 8-bit/16-bit I/O module specifically designed to communicate with a wide variety of parallel devices such as communications peripherals, LCDs, external memory devices and microcontrollers. Because the interfaces to parallel peripherals vary significantly, the PMP module is highly configurable."

The driver makes use of the Parallell Master Port (PMP) in Master mode (mode set by PMP_MASTER_1), in which the following Special Function Registers (SFRs) apply:

PMCON: Parallel Port Control Register

This register (Register 13-1) contains the bits that control much of the module's basic functionality. A key bit is the ON control bit, which is used to Reset, enable or disable the module. When the module is disabled, all of the associated I/O pins revert to their designated I/O function. In addition, any read or write operations active or pending are stopped, and the BUSY bit is cleared. The data within the module registers is retained, including the data in PMSTAT register. Therefore, the module could be disabled after a reception, and the last received data and status would still be available for processing. When the module is enabled, all buffer control logic is reset, along with PMSTAT. All other bits in PMCON control address multiplexing, enable various port control signals, and select control signal polarity. For futher details, see PIC32 Family Reference Manual [3] Chapter 13.3.1 Parallel Master Port Configuration Options.

PMMODE: Parallel Port Mode Register

This register (Register 13-2) contains bits that control the operational modes of the module. Master/Slave mode selection, as well as configuration options for both modes, are set by this register. It also contains the universal status flag BUSY, used in Master modes to indicate that an operation by the module in progress. For futher details, see PIC32 Family Reference Manual [3], Chapters 13.4 Slave Modes of Operation and 13.3 Master Modes of Operation.

PMADDR: Parallel Port Address Register

This register (Register 13-3) functions as PMADDR in master modes. It contains the address to which outgoing data is to be written, as well as the Chip Select control bits for addressing parallel slave devices. The PMADDR register is not used in any of the Slave modes.

PMAEN: Parallel Port Pin Enable Register

This register (Register 13-6) controls the operation of address and Chip Select pins associated to this module. Setting these bits allocates the corresponding microcontroller pins to the PMP module; clearing the bits allocates the pins to port I/O or other peripheral modules associated with the pin.

References

[1] See the Electronic Assembly web site on their display-on-glass (DOG) series at http://www.lcd-module.com/products/dog.html

[2] Electronic Assembly DOG Series 3.3V, Technical datasheet, Issue 1.2010. dog-me.pdf [1.32 MB].

[3] Microchip PIC32MX Family Reference Manual, Section 14. Parallell Master Port. DS-61128E.pdf [715 kB].

[4] For suppliers of the Electronic Assembly DOG-M series and corresponding backlights, see https://www.elfa.se/elfa3~se_en/elfa/init.do?query=DC-76206&in=fam (display) and https://www.elfa.se/elfa3~se_en/elfa/init.do?query=DC-76207&in=fam (backlight modules).

Return to previous page

Leave a message

Your name:

Your email: (required)

Message:

Generated by ::emailform::

Last modified Wednesday 15 Feb 2023