This is a more detailed explanation of PIC16F interfacing HD44780 compatible Character LCD DisplaySimilar assembly code example was used in a number of recently published projects.2 PORTs are required: one for Data, in this example PORTD, the other PORT is PORTE for controlling the LCD (only 2 bits are needed).The subroutine can be modified to fit other PICs by changing their PORT assignment. LCD W/R is connected to ground, so we can only write to LCD.8 bits of LCD Data lines (D7-D0) are connected to PORTD. Enable pin E, and RS line to PE0,1.
Set DDRAM Address Command is used to define a location on the Display. If you look closely you’ll see that MSB bit for this command is constantly set to “1” ,so the actual address for Lines1,2 will start with 0x80 for line 1 and 0xc4 for line 2. See attached instruction table.
Here is a simplified sequence for writing the Data and Command to LCD Display. Output a Command to PORTD according to LCD Instruction Code table, clear RE1 set RE0 to “1” for more than 150ns.For Data the process is almost identical. Send Data to PORTD, set RE0,RE1 to “1” for more than 150ns. In the next table you can see initialization sequence.
The following assembly code will show * on LCD. It was used to test display operation. Change the output ASCII code to display additional characters.