8- bit mode in LCD Display

Thread Starter

Gajyamadake

Joined Oct 9, 2019
310
Hi There

I have question regarding LCD display 16*2. LCD display is use to display data from micro-controller. We can send the string of character to LCD in two mode (4 bit and 8 bit mode). I understand we uses 4 I/O port pins for data in 4-bit mode and 8 I/O port pins for data in 8-bit mode

What happen in 4 bit-Mode? Do we send only 4 bit data to LCD from Microcontroller ?
What happen in 8 bit-Mode? Do we send only 8 bit data to LCD from Microcontroller ?
 

AlbertHall

Joined Jun 4, 2014
12,346
In 8 bit mode you send a byte in one 8 bit transfer.
In 4 bit mode you send a byte in two 4 bit transfer. The byte is split into two 4 bit nibbles and they are sent separately to the LCD which combines them together again.
 

jpanhalt

Joined Jan 18, 2008
11,087
The difference in speed between 4-bit and 8-bit mode is so small as to be insignificant. The data are sent sequentially with a toggle of E (enable). After both nibbles are sent, you then wait whatever is required (about 40 us). I usually just read the ready pin instead of using a fixed wait.
 

Thread Starter

Gajyamadake

Joined Oct 9, 2019
310
In 4 bit mode you send a byte in two 4 bit transfer. The byte is split into two 4 bit nibbles and they are sent separately to the LCD which combines them together again.
I didn't understand the concept of splitting into two 4 bit nibbles

For example In 8 bit we are sending one byte data 'A' to LCD If we want to send one character 'A' from microcontroller to LCD. It occupy 8 bit memory. I don't understand how character 'A' transfer in 4 bit mode ?
 

MrChips

Joined Oct 2, 2009
30,806
Let us take the example of the character 'A'.
The 8-bit code for 'A' is 0100 0001.
In 4-bit mode, we split the 8-bit value into two 4-bit parts (called high nibble and low nibble).
The high nibble is 0100. This is sent first. The low nibble is 0001 and this is sent following the high nibble.
 

Thread Starter

Gajyamadake

Joined Oct 9, 2019
310
Let us take the example of the character 'A'.
The 8-bit code for 'A' is 0100 0001.
In 4-bit mode, we split the 8-bit value into two 4-bit parts (called high nibble and low nibble).
The high nibble is 0100. This is sent first. The low nibble is 0001 and this is sent following the high nibble.
Thanks to point I understand now the basic difference between two mode. My second question is which one mode is more useful and why it's useful ?

I think 8 bit mode is more useful because it takes less time to send data to LCD
 

AlbertHall

Joined Jun 4, 2014
12,346
I think 8 bit mode is more useful because it takes less time to send data to LCD
This is true if you have eight spare pins. It is also easier to get the code for setting up the LCD correct. Setting up for 4 bit mode is one of the places where folk have problems with these displays.
 

jpanhalt

Joined Jan 18, 2008
11,087
I think 8 bit mode is more useful because it takes less time to send data to LCD
As I pointed out above, the time difference is very small. To pin it down you need details. In general, the data byte is in WREG. You send it, then do a swapf and send again or visa versa, then wait. That wait is about 40 us. The extra "send" is less than 8 steps. At 16 MHz, that's less than 2 us.
 

atferrari

Joined Jan 6, 2004
4,769
After writing my routine for a 2*16 LCD I realized that, as long I am not writing to the RAM inside I do not need to check the BUSY flag. I grounded that pin and use instead a fixed on-line delay.
 

MrChips

Joined Oct 2, 2009
30,806
As @AlbertHall pointed out in post #9, 8-bit mode is less problematic. Sometimes 4-bit mode will not initialize properly and requires extra effort to get properly synchronized.

If you can dedicate an 8-bit port (plus 3 I/O pins for RS, R/W, E) then go with 8-bit mode.
 

jpanhalt

Joined Jan 18, 2008
11,087
Sometimes 4-bit mode will not initialize properly and requires extra effort to get properly synchronized.
If you can dedicate an 8-bit port (plus 3 I/O pins for RS, R/W, E) then go with 8-bit mode.
1) Please show an example of 4-bit mode not initializing properly. I can't believe it is random, rather then bad code.
2) Why waste pins. The deference in speed is insignificance, particularly if one is using "C" or a fixed delay.
 

AlbertHall

Joined Jun 4, 2014
12,346
Please show an example of 4-bit mode not initializing properly. I can't believe it is random, rather then bad code.
If you look through the forums there is no shortage of such problems. There are possibly two main causes: bad code copied from WWW; differences in the displays (chinese copies?).

It is difficult to diagnose as, until the initialisation is correct, the display is blank so there are no clues.
 

jpanhalt

Joined Jan 18, 2008
11,087
If you look through the forums there is no shortage of such problems. There are possibly two main causes: bad code copied from WWW; differences in the displays (chinese copies?).

It is difficult to diagnose as, until the initialisation is correct, the display is blank so there are no clues.
No shortage of problems? Thanks for confirming my assertion. Yes, bad code will cause problems, as one might expect.

Provide one example of "good" code that provides problems. That was the challenge I presented to @MrChips.
 
Top