Re: LCD init code ...safety
Quote:
Originally Posted by
Darrel Taylor
One thing that can cause garbage characters like that is when a 4-bit interface gets out of sync, and it gets the low nibble from the last byte with the high nibble of the next byte.
Sometimes you can toggle the E line once to get it back in sync, but to detect when to do that you need to have the R/W line connected to the PIC so you can see the busy flag. If it's not busy for 1.6mS after giving it a clear screen command ($FE,1) then it's probably out of sync.
With an 8-bit interface that error can't happen.
You can also re-initialize the LCD by clearing PBP's FLAGS system variable.
On the next LCDOUT statement it will start from scratch as if power was turned on.
Code:
FLAGS = 0
LCDOUT $FE,1
In some cases, an LCD cannot be reset from software. It takes a power down sequence.
If the LCD is powered from a PIC pin, you can cycle power to the LCD, then clear the FLAGS variable.
thanks for all the HELP and hints.
Darrel , i ve no words to express my gratitude :rolleyes: !
You were 100% right, i used 4 bits data bus...and sometimes it was out of sycn.
you really save my day.
Note: i ve this card connected to another one that powers a 30A relay ...i guess the problem is here ( and i cannot redesign this card for zero crossing on-off...). Also a lot of cables are going thru the unit, and the FLAT cable i use to connecto to the LCD is probalby receiving a lot of EMF...).
I have the FLAG option now to reset from time to time ( also i need to program again the CGRAM ) and i will make another PCB with 8bits Data Bus.
!!!! REALLY THANKS !!!!
PS: where can i see a full desciption of what the FLAGS = 0 does in terms of the full registers/code that is running in the CPU ( i am using almost every juice i can get from the 32K of the 18f4520 ;-)