4 LCD Module Configuration Example

The following code snippet demonstrates the initialization of the LCD module found on the PIC16F19197 microcontroller to interface a custom Variation 5.0V LCD panel. The LCD charge pump found on this family of devices allows the microcontroller to operate from 3 AAA batteries using a regulated VDD of 3.3V, while driving the LCD panel at 5.0V. The LCD charge pump was enabled by setting LCDPEN of Configuration Word 1, and the LCD voltage source was selected to be provided from the LCD charge pump only without the use of internal or external resistor ladder. Low-Power (Low-Current) mode of the LCD charge pump was enabled, and the charge pump was configured to generate voltages in the 5.0V voltage range to meet the requirements of the LCD panel. The boost pump output voltage was also programmed to generate an output of 5.01V (the maximum voltage from the charge pump). LCD Module Configuration (PIC16F19197 Low-Power Touch Enabled LCD Demo) below shows the initialization routine used to configure the LCD module and internal LCD charge pump to drive this display.

LCD Module Configuration (PIC16F19197 Low-Power Touch Enabled LCD Demo)

LCDCONbits.LCDEN = 0; // Disable module before configuring;
LCDPS = 0x02; // LP 1:3; WFT Type-A waveform;
LCDREF = 0x00; // LCDCST Max contrast (Min Resistance);
LCDRL = 0x00; // LRLAP disabled; LCDIRI disabled; LRLAT Always B Power mode;

LCDVCON1 = 0xC7; // BIAS 5.01V; EN5V enabled; LPEN enabled;
LCDVCON2 = 0x86; // CPWDT disabled; LCDVSRC Charge Pump only;

            LCDSE0 = 0xFF; // Enable used segments;
            LCDSE1 = 0x3F; // Enable used segments;
            LCDSE2 = 0xF8; // Enable used segments;
            LCDSE3 = 0xBF; // Enable used segments;
            LCDSE4 = 0xC0; // Enable used segments;
            LCDSE5 = 0x3E; // Enable used segments;

LCDCON = 0xC8; // CS LFINTOSC; SLPEN disabled; LMUX 1/8 COM(7:0);
LCDCONbits.LCDEN = 1; // Enable Module;