Well, after that nice diversion, here's an update that is a little more OT. I set up TMR1 to time my WNB (wait not busy) routine. I simply have a push button to cycle through the letters and positions. Later, I will measure the time for a whole line, but tomorrow I will be in Cleveland, and wanted to give a preliminary result,crude as it may be.
I measure the WNB for printing an "H" in the first line, first position. The average time was 27.5 usec and the range (n=6) was 25.5 to 30 usecs. In fact, only two values, 25.5 usec (0x33 Tcy) and 30 usec (0X3C Tcy) were recorded. That difference is consistent with one additional check Busy loop.
Here's the code for those interested. I may not get back to this until Thursday.
John
I measure the WNB for printing an "H" in the first line, first position. The average time was 27.5 usec and the range (n=6) was 25.5 to 30 usecs. In fact, only two values, 25.5 usec (0x33 Tcy) and 30 usec (0X3C Tcy) were recorded. That difference is consistent with one additional check Busy loop.
Here's the code for those interested. I may not get back to this until Thursday.
John
Code:
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