An example C program is given here to show how the LCD can be set up. The connection of the LCD to the microcontroller is shown in Figure 6.9 (if you are using the EasyPIC 7 development board, all you have to do is just connect the LCD to the board). PORT B lower pins (RB0 to RB3) are connected to the upper 4 bits of the LCD (DB4 to DB7). In addition, RB4 and RB5 pins are connected to LCD RS and E pins, respectively.
The program listing is shown in Figure 6.10. The following functions are used in the program:
The LCD setup functions are tested by the main program in Figure 6.10. Here, PORT B pins are configured to be output. Then the LCD is initialised by calling Lcd_Initialise and LCD is cleared by calling function Lcd_Clear. The text ‘Hello’ is then sent to the LCD by using function Lcd_Write_Char, where each character is sent individually using a for loop.
3.145.166.167