Issue with reading busy flag in 4 bit mode.

Comments

6 comments

  • Swemarv

    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
  • Michael_L

    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
  • Swemarv

    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
  • richardwright

    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
    RET
    0
  • Michael_L

    The byte order should remain the same between compatible controllers.

    0
  • acain829

    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 command

    Cheers

    Andy

    0

Please sign in to leave a comment.