The LCD I use for this project is the same as in the 4-bit mode experiment: LCM-S01602DSR manufactured by Lumex. It has 2 rows of 16 characters and uses a 5x8 font. It turns out that the contrast adjustment is really not needed, I run the LCD at maximum contrast by grounding its contrast adjustment pin. Also, I do not poll the LCD controller status, just provide long enough delays in the code so that LCD could catch up. Sending a character takes less than 6msec, so the entire display is filled before my eye can twinkle.
The LCD 8-bit mode requires at least 10 control pins from PIC, so I use a separate PIC16F684 to drive the LCD. The test string "Welcome to PIC Programming" is send by another PIC (12F683) by using a two-wire interface.
Schematic | Layout | |
The LCD controlling PIC interface lines are initially pulled up high by using two 2K2 resistors. When the sender needs to send a byte, it lowers the clock line first, posts a bit on the data line and raises the clock. The rising edge of the clock line generates an interrupt that reads the value from the data but and shifts it into the receiving byte. As soon as 8 bits are received from sender, the composed byte is sent to the LCD. The receiving PIC pulls the clock line down at the beginning of the interrupt and releases it upon processing a bit or byte. The sender polls the clock line and postpones sensing a new bit until the clock line becomes high. This way the clock line is bidirectional and is used for input and output by both sender and receiver, while the data line is used for sending the data in one direction only.
On the sender's part, the messages to display (msg1 and msg2) are stored as read-only arrays. The function writeLCD implements the interface described above. The message is send to the LCD driving PIC every time when the button is clicked. In the present implementation it is assumed that only the characters from the lower part of the ASCII table (range 0 - 127) will be displayed. The range 128 - 255 is intended to send an instruction to the LCD (like clear the screen, or move the cursor). The receiver must set bit 7 for every native LCD instruction byte. The driving PIC uses this bit to distinguish between the data and commands and sends it to the R/S pin of the LED controller.
The LCD driver is assembled on a small PCB and attached to the back side of the LCD board. This way only 4 wires need to be connected with the test circuit: two for the power, the clock, and the data lines. All 12 I/O of the driving PIC are used: 10 of them for interfacing with the LCD and two for interfacing the sender. The read-only input of the PIC (RA3) is used for the data line.
Board layout | Board assembly | Front view | ||
Last modified:Mon, Jan 23, 2023.