Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

16X2 Character Display Fills Screen

Status
Not open for further replies.
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

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
 
Hi John,

Very interesting idea, to actually measure the times for various instructions to complete.
I also wonder if there might be some variance like when we send a bunch of characters, will the last one take longer.
Also, supposedly the clear instruction takes the longest or at least somewhat longer. You might want to time test that too.
 
Follow-up to post #45

I measured the time for printing A through P (16 characters) on one line. Average time per character after collecting multiple readings ranged from 42.5 us to 46 us. Those results include overhead that was not included in the WNB loop alone.

For anyone who might be interested, here's the pertinent section of code:
Code:
Loop
     movlw     0x01                ;clear screen
     call      PutCmd
     DelayCy   (2*msecs)         
    movlw     0x80             ;set LCD address (left char of first line)
    call      PutCmd
;print full row of sequential ASCII characters and get elapsed time
     clrf      TMR1H
     clrf      TMR1L
     movlw     'A'
     movwf     asciival
Repeat
     bsf       T1CON,TMR1ON      ;start TMR1
     movf      asciival,w  
     call      PutDat
     bcf       T1CON,TMR1ON      ;stop TMR1
     incf      asciival,f
     movf      asciival,w
     sublw     'P'             ;'P' = 16th ascii character printed   
     btfsc     STATUS,0
     bra       Repeat    
     call      PutReg
     call      DlyLong
     goto      Loop

"PutReg" is the routine to print the values in TMR1H/L to a serial 2X16 LCD. DlyLong is a 1 second delay, so I could record the values.

John
 
As requested I have split out the posts discussing random start-up 4 bit or 8 bit mode to a new thread.

JimB
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top