Thanks, that site is very helpful. Wesley Moore wrote: > I would suggest you visit the following page. It has truck loads of info > related to LCD's as well as source for the various aspects of LCD control > including the busy flag. > > http://www.iaehv.nl/users/pouweha/lcd2.htm > > ___________________________________________ > Wesley Moore > RMIT - BEng/BApp.Sc. 1st Year > > wmoore@cs.rmit.edu.au > http://wmoore.tsx.org/ > > On Mon, 25 Oct 1999, John Considine wrote: > > > I am having a problem when I try to check the busy flag coming from the > > LCD display (BUSY_FLAG? subroutine shown below). It is always busy but > > if I remove the busy flag check it runs fine, as long as I use a slow > > clock (therefore the display must not be busy). Any suggestions why > > this bit would be remaining high. the power supply is a 7805 (5+) > > being supplied by a 1 amp 12v power supply (120V wall plug in). I have > > a .1uf capacitor from +5 to ground and a .57uf cap from 12V to ground > > (for decoupling so I think). All of this is on a breadboard along with > > the PIC 16C84 and Noritake LCD display 4X20 display with selectable 4 or > > 8 bit transfer. > > Thanks. > > > > ;October 25, 1999 > > ; > > > > > > LIST P=16C84, F=INHX8M, R=DEC > > include > > __CONFIG _CP_OFF & _WDT_OFF & _RC_OSC > > > > DISP_ON EQU b'00001101' > > CLR_DISP EQU b'00000001' > > ENTRY_INC EQU b'00000110' > > MSD EQU H'0C' > > LSD EQU H'0D' > > TEMP EQU H'0E' > > TEMP1 EQU H'0F' > > CHAR EQU H'10' > > RESET_V EQU 0 > > LCD_DELAY_SET EQU H'FF' > > DD_RAM_ADD EQU H'80' > > E EQU 4 ; LCD Enable control line > > RW EQU 3 ; LCD Read/Write control line > > RS EQU 2 > > ;interupt routine varibles > > INT_W EQU H'11' > > INT_S EQU H'12' > > > > org 0 > > RESET goto START > > org 4 ; RESET vector location > > > > Int > > movwf INT_W > > movf STATUS, 0 > > movwf INT_S > > > > START > > ;pic 16c84 setup for initial state > > movlw b'00000000' > > movwf STATUS ;Clear Status > > clrf INTCON ;Initialize INTCON Disable all interupts > > ; bsf INTCON, 3 ;Makes interupt if RB<7:4> change state > > bsf STATUS,RP0 > > movlw b'11000111' > > movwf OPTION_REG ;Set Option Register > > bcf STATUS,RP0 > > > > clrf PORTA > > clrf PORTB > > bsf STATUS,RP0 > > CLRF TRISA > > CLRF TRISB > > bcf STATUS,RP0 > > > > ;display initialize > > > > movlw H'20' ;four bit transfer =h'20' 8 = h'38' > > movwf PORTB > > bsf PORTA,E > > bcf PORTA,E > > > > movlw DISP_ON > > > > nop > > nop > > nop > > nop > > nop > > movwf PORTB > > call CMD_SEND > > > > ; movlw CLR_DISP > > ; call CMD_SEND > > > > ;send characters > > movlw 'F' > > call CHAR_REC > > movlw 'I' > > call CHAR_REC > > movlw 'N' > > call CHAR_REC > > movlw 'A' > > call CHAR_REC > > movlw 'L' > > call CHAR_REC > > > > goto $ > > > > > > > > CMD_SEND > > movwf CHAR ; Command to be sent is in W > > call BUSY_FLAG? ; Wait for LCD to be ready > > movf CHAR, 0 > > movwf PORTB ; Send data to LCD > > bcf PORTA, RW ; Set LCD in read mode > > bcf PORTA, RS ; Set LCD in command mode > > bsf PORTA, E ; toggle E for LCD > > bcf PORTA, E > > ;send lower nibble > > swapf CHAR, 0 > > movwf PORTB > > bsf PORTA, E > > bcf PORTA, E > > RETURN > > > > CHAR_REC > > movwf CHAR ; Command to be sent is in W > > call BUSY_FLAG? ; Wait for LCD to be ready > > movf CHAR, 0 > > movwf PORTB ; Send data to LCD > > bcf PORTA, RW ; Set LCD in read mode > > bsf PORTA, RS ; Set LCD in command mode > > bsf PORTA, E ; toggle E for LCD > > bcf PORTA, E > > ;low nibble transfer > > swapf CHAR,0 > > movwf PORTB > > bsf PORTA, E > > bcf PORTA, E > > RETURN > > ; > > BUSY_FLAG? > > > > bsf STATUS,RP0 ; Select Register page 1 > > movlw 0xF0 ; Set port_B for input > > movwf TRISB > > bcf STATUS, RP0 ; Select Register page 0 > > bcf PORTA, RS ; Set LCD for command mode > > bsf PORTA, RW ; Setup to read busy flag > > bsf PORTA, E ; Set E high > > bcf PORTA, E ; Set E low > > movf PORTB, 0 ; Read busy flag, DDram address > > andlw 0xF0 > > movwf TEMP > > bsf PORTA, E > > bcf PORTA, E > > swapf PORTB, 0 > > andlw 0x0F > > iorwf TEMP > > btfsc TEMP,7 > > ; goto BUSY_FLAG? > > nop > > bsf STATUS, RP0 > > movlw 0x00 > > movwf TRISB > > bcf STATUS, RP0 > > RETURN > > > > ; movwf > > ; movwf TEMP > > ; btfsc TEMP, 7 > > ; ; Check busy flag, high=busy > > ; goto BUSY_FLAG? > > ; bcf PORTA, RW > > ; bsf STATUS, RP0 ; Select Register page 1 > > ; movlw H'00' > > ; movwf TRISB ; Set port_B for output > > ; bcf STATUS, RP0 ; Select Register page 0 > > ; RETURN > > > > end > >