Issue with reading busy flag in 4 bit mode.
Hi
I have a NHD-C0220AA-FSW-FTW display that I have problems reading the busy flag from in 4 bit mode. To understand what is going on I connected my logic analyser to the datalines and the controll lines.
As I understand the datasheet of the controller, when reading the busy flag ( and the address of the AC) the high nibble is sent from LCD first and then the low nibble. But when I look what is on the datalines it looks like the low nibble is sent first and then the high nibble
I implemented this into my program where I do a clear and then wait for busy flag to send a number of characters, and suddenly it worked. I did a measurement just after a clear command, according to data sheet this should take 1.64ms.
First directly after clear command, cursor one is positioned at the falling edge of second enable signal.
I read the data 1us after the enable has been set to one. It is clear that the first nibble sent by the LCD is not with the busy flag set (D7) when it should, but the second nibble has the D7 set.
After about 1.6 ms D7 finaly goes low, this corresponds well with the specified time after a clear.
it is also possible to read the AC after characters are sent, and it counts up as it should if I interpret the first nibble sent from LCD as the low nibble and not the high as is specified in the datasheet.
I manage to get the code working when implementing this change but I feel reluctant to use it since it is not according to the datasheet.
Does anyone have experienced the same thing or have a solution or suggestion on what I am doing wrong ?
Thanks
-
Since this forum is linked from Newhaven site, I assumed that any product support related questions would be answerd in this forum.
I need an explanation for the strange behaviour of my LCD.
Can anybody help me out ?0 -
I am having trouble finding where in the datasheet it shows the high nibble is read first. I'm guessing you have assumed this based off the fact that when writing to the controller the high byte must be sent first, but it seems as you have proven, this is not the case. If I am not mistaken, your code is working now right?
0 -
On page 5 in the LCD spec there is a link to the driver specification. on page 23 in the driver specification you can see that the high nibble should be put out first.
0 -
ust to clarify here. In the manual for the ST7066U controller on page 26 there is a series of routines exemplifying 4-bit operation. One of the routines is a check busy path. It seems in that example the busy flag appears to be transferred in the first nibble. The pins are read as part of the first strobe when E is set high but the pins are ignored when E is strobed the second time.
Does the byte order varying between LCD models with similar controllers?>>Snip
CHK_BUSY: ;Check Busy Flag
PUSH A
MOV P1,#FFH
$1
CLR RS
SETB RW
SETB E
MOV A,P1 <====This appears to be the only time the pins are read. E is strobed both here as well as a few instructions down though.
CLR E
MOV P1,#FFH
CLR RS
SETB RW
SETB E
NOP <====The pins are ignored
CLR E
JB A.7,$1
POP A
RET0 -
The byte order should remain the same between compatible controllers.
0 -
Hello everyone.
Just registered because I wanted to reply to this post. I know it's old but I was struggling with the same issue as the OP. I am using an LCD 16x2 display in 4 bit mode and I could not get my busy flag check routine to work. Turns out that it was because I was only strobing the Enable Flag once so the controller was waiting to send the second nibble and I had already started sending more commands. In my case the upper nibble is sent first (ie. D7 is sent in the first nibble). My code is below in Microchip ASM. Hopefully this helps anyone with a similar problem.Check_BF bsf STATUS,RP0 ;Set Bank 1
movlw b'00001111'
movwf TRISD ;Sets LCD pins as inputs to read busy status
bcf STATUS,RP0 ;Bank 0
busy bsf LCD_PORT,LCD_RW ;LCD to read mode
bcf LCD_PORT,LCD_RS ;LCD to command mode
bsf LCD_PORT,LCD_E ;Enable line high
nop
movfw LCD_PORT ;Move low nibble PORT data to W
bcf LCD_PORT,LCD_E ;Enable line low
movwf busy_var
bsf LCD_PORT,LCD_E ;Enable line high
nop
bcf LCD_PORT,LCD_E ;Enable line low
btfsc busy_var,3 ;Test bit 3 (Busy flag) to see if it is high or low
Goto busy
NotBusy bsf STATUS,RP0 ;Set Bank 1
movlw b'00000000'
movwf TRISD ;Sets LCD Port back to output
bcf STATUS,RP0 ;Return to Bank 0
bcf LCD_PORT,LCD_RW ;Back to write mode
Return ;Busy flag 0, LCD ready for next commandCheers
Andy0
Please sign in to leave a comment.
Comments
6 comments