This is a JHD162A LCD display example.
Please have a look at LCD TUTORIAL and JHD162A
As you see a LCD display includes two groups of pins:
1. Control pins, these are: Register select RS we can select to send comands or data to the LCD, Read/write pin R/W and finaly Enable E pin to fetch comands or data during a transition from high to low state of this pin.
2. Data pins. We use here an eight bits data bus but there is the ability to use only a four bits data bus, saving pins of the parallel port.
LCD's timing needs precise time delays of a few of msec so we use timer T3. A delay() function is:
void delay_T3 (unsigned int t)
{
GPT12E_T3IC_IR =0; // Reset IR bit
GPT1_vLoadTmr_GPT1_TIMER_3(t);
GPT1_vStartTmr_GPT1_TIMER_3();
while (GPT12E_T3IC_IR!=1 ); //wait for timer T3 to overflow
GPT1_vStopTmr_GPT1_TIMER_3();
}
waiting for the change of the logic state of the interrupt request bit of T3 when overflows.
see Keil timer delay
For educational purpose we use here a time delay of about 280 msec.
So, run the C code at simulator opening the serial window #1 and watch the
result.
Next: A four bit data bus LCD example.
* printf() functions are used in the code for educational purpose only. You have to remove them in practice.
|