8- bit mode in LCD Display

MrChips

Joined Oct 2, 2009
34,817
I have experienced problems in the past with 4-bit mode. There was nothing wrong with the code. The procedure that worked was to call the initialization routine twice.
 

dendad

Joined Feb 20, 2016
4,638
I use the 4 bit mode, but with the I2C interface all the time now.
I2C_LCD1.png
I2C_LCD2.png
So you only need 2 pins, plus 5V and gnd.
And a number of displays, or other I2C devices can be run on the same pair of pins too as long as the addresses are different.
That may be worth a look.
 

MrChips

Joined Oct 2, 2009
34,817
If you want to take that route you can do it with 1 pin plus Vcc and GND.
UART signalling, 1-wire. I have implemented an addressable Manchester phase encoded signalling.
 

BobTPH

Joined Jun 5, 2013
11,517
I have experienced problems in the past with 4-bit mode. There was nothing wrong with the code. The procedure that worked was to call the initialization routine twice.
Which points to possibly not a long enough wait at power up. These displays require quite a long time to initialize.

Bob
 

jpanhalt

Joined Jan 18, 2008
11,087
I have experienced problems in the past with 4-bit mode. There was nothing wrong with the code. The procedure that worked was to call the initialization routine twice.
I would take that as evidence of a code problem.

Not to initiate another long discussion, but some people believe that the Hitachi chip comes up natively in 4-bit mode. That is, one can use 4-bit commands to set 8-bit mode, but one does not need to use 8-bit commands to set 4-bit mode..
 

jpanhalt

Joined Jan 18, 2008
11,087
Thanks for the response.

I have at times wanted to read, modify, and write a position -- like scrolling a GLCD or erasing only the remainder of a line. Also, I tend to use the busy flag rather than fixed delays when relevant.
 

atferrari

Joined Jan 6, 2004
5,012
I always wonder this: say you start checking the busy flag of an LCD that is not working. You risk to get stuck forever there...unless your error checking structure is robust enough. Anyone?
 

ericgibbs

Joined Jan 29, 2010
21,443
hi at,
Any program action that waits for an input, should have a 'time out' escape route, this could be a simple loop counter or a Interrupt/Timer.
E

Update:
On my radio linked data logger, I use a 8 pin PIC 12F628 that monitors the RX and TX activity etc... , if the Time Out occurs It Resets the main MCU.
Works fine.
E
 

ericgibbs

Joined Jan 29, 2010
21,443
hi j,
Its a radio receiver link [HC12] which expects data reception every 2 seconds ,the RX MCU then combines the received data with local data and retransmits the combined data on a different radio channel to a 'master' receiver'.
Trying a 'software' approach did not give the required performance due occasional interference from other TX/Rx users in the area.

So I adopted an approach which worked well on my commercial products, you may know of the IC's that monitor a number of lines the MCU uses as part of the programs operation and generates a Reset if they are absent for a given time period.

So monitoring the TX and RX and the SD card data integrity of the main MCU, by using a small PIC, its possible to give the system a reliable Reset operation.
Running now for over 3 years, 24/7, with minimal problems.

E
 

nsaspook

Joined Aug 27, 2009
16,328
Is that really practical with synchronous routines such as SPI? It seems a timeout, such as WDT is reliable and has a place.
SPI can be configured for buffers and interrupts (and/or DMA on some devices) so blocking waits for word transfers should be the last option for efficient high speed operation. Most of my small embedded devices use SPI mode displays in an FSM that never waits for individual I/O(s).
 

ericgibbs

Joined Jan 29, 2010
21,443
hi,
Never seen a program written yet that can guarantee when 'glitched' by noise or a component tolerance failure,that will not get into a 'forever loop' which is outside the main programs software time out loops.
In a critical MCU project I would always add a hardware device time out reset, in addition to any software time out resets.

E
 

nsaspook

Joined Aug 27, 2009
16,328
hi,
Never seen a program written yet that can guarantee when 'glitched' by noise or a component tolerance failure,that will not get into a 'forever loop' which is outside the main programs software time out loops.
In a critical MCU project I would always add a hardware device time out reset, in addition to any software time out resets.

E
Correct. There is no solution to the 'Halting Problem' in a Turing machine but that's really a separate issue IRT blocking I/O functionality.
 

joeyd999

Joined Jun 6, 2011
6,300
hi,
Never seen a program written yet that can guarantee when 'glitched' by noise or a component tolerance failure,that will not get into a 'forever loop' which is outside the main programs software time out loops.
In a critical MCU project I would always add a hardware device time out reset, in addition to any software time out resets.

E
I've got tens of thousands of product in use in the field running with no WDT for up to 30 years.

None "hang up". Ever.
 

ericgibbs

Joined Jan 29, 2010
21,443
hi j,
Congrats, so have I, worldwide.
My MCU products also did not hang up, using HW and SW 'anti-hanging' routines.
Guess we both know what we are doing, good to hear.;);)

E
 
Top