Author Topic: Issue with reading busy flag in 4 bit mode.  (Read 4948 times)

Swemarv

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Issue with reading busy flag in 4 bit mode.
« on: September 29, 2014, 01:54:24 AM »
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 bysy 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.

I have attached two figures.
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

Swemarv

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Issue with reading busy flag in 4 bit mode.
« Reply #1 on: October 01, 2014, 07:16:43 AM »
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 ?


Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Issue with reading busy flag in 4 bit mode.
« Reply #2 on: October 02, 2014, 08:20:39 AM »
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?

Swemarv

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Issue with reading busy flag in 4 bit mode.
« Reply #3 on: October 07, 2014, 02:32:20 AM »
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.
See attachment.

richardwright

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Issue with reading busy flag in 4 bit mode.
« Reply #4 on: December 09, 2014, 08:50:54 AM »
Just 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
RET

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: Issue with reading busy flag in 4 bit mode.
« Reply #5 on: December 10, 2014, 08:39:58 AM »
The byte order should remain the same between compatible controllers.

acain829

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: Issue with reading busy flag in 4 bit mode.
« Reply #6 on: September 26, 2015, 10:12:49 AM »
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.

Code: [Select]
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 command

Cheers

Andy

 

NHD‐3.5‐320240MF‐ATXL#‐CTP‐1 Problem with standby mode

Started by guenterBoard TFTs

Replies: 0
Views: 1933
Last post June 16, 2016, 12:14:36 PM
by guenter
NHD-0420H1Z-FL-GBW-33V3 pull-ups and pull-downs in 4 bit mode

Started by richardwrightBoard Character LCDs

Replies: 3
Views: 2993
Last post December 15, 2014, 05:12:27 PM
by Michael_L
NHD0420CW-A*3 tHREE LINE MODE, MIDDLE LINE DOUBLE HEIGHT

Started by wb2dybBoard OLEDs

Replies: 3
Views: 3100
Last post July 01, 2015, 09:49:46 AM
by Paul_B
NHD-2.4-240320CF-CSXN#-F works in 18 bits(262K colors) mode

Started by charlieBoard TFTs

Replies: 3
Views: 2149
Last post March 15, 2016, 10:39:50 AM
by Saurabh_B
Text orientation not changing with Extended Entry Mode Set Register

Started by tekknojoeBoard OLEDs

Replies: 5
Views: 1385
Last post January 27, 2017, 10:13:57 AM
by jmadsenee