WNB ;WaitNotBusy -- working
clrf TMR1H ; |B0
clrf TMR1L ; |B0
bsf T1CON,TMR1ON ;turn TMR1 on |B0
bcf STATUS,0 ;set up Carry bit as RS flag
btfsc RS
bsf STATUS,0
banksel TRISC ; |B1
movlw 0x0F ;BF requires reading the whole port |B1
movwf TRISC ;PORTC bits<0:3>set as inputs |B1
banksel PORTC ; |B0
bcf RS ;read BF Cmd
bsf RW
Busy
bsf E
bcf E
movf PORTC,w ;high nibble from LCD is in low nibble of port
movwf temp ;move high nibble to temp, NB: DB7 is in temp,3
bsf E ;have to read twice, second nibble ignored
bcf E ;required 2nd read, do notneed to move it
btfsc temp,3 ;temp,3 = DB7 from first read
goto Busy ;busy, test again
bcf RW ;BF is clear, reconstruct TRISB, RS, and return
banksel TRISC ; |B1
clrf TRISC ; |B1
banksel PORTA ; |B0
bcf RS
btfsc STATUS,0
bsf RS
bcf T1CON,TMR1ON ;turn TMR1 off, TMR1 control adds 4 Tcy (2 us) |B0
return