Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - acain829

Pages: [1]
Character LCDs / Re: Issue with reading busy flag in 4 bit mode.
« 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
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
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



Pages: [1]