Searching \ for 'NOP's needed??' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=nops+needed
Search entire site for: 'NOP's needed??'.

Truncated match.
PICList Thread
'NOP's needed??'
1998\02\27@124629 by H.P.d.Vries

flavicon
face
I've created (yet another) 4x4 matrix keyboard decode-routine.
I've placed 4 NOP's in it, because in a similar routine, they also were
there (bad reason) , but I'm not sure if they are needed.
They are there to let the output-pins when the pattern on portb is
changed. But are they nescessary?

Scan_4x4        ****************        ;OK
       CLRF    Key                     ;Returns: key value in Key
       MOVLW   .4                      ;No keypress:   Key = b'00010000'
       MOVWF   Counter
Scan_loop
       MOVF    Mask,W                  ;Mask
       MOVWF   PORTB                   ;Put mask on port
       NOP                             ;Let pins settle
       NOP                             ;But is this nescessary??
       NOP
       NOP
       NOP
       NOP
       BTFSS   PORTB,0                 ;IS first bit clear?
       RETURN                          ;Yes, so that row was pressed
       INCF    Key
       BTFSS   PORTB,1
       RETURN
       INCF    Key
       BTFSS   PORTB,2
       RETURN
       INCF    Key
       BTFSS   PORTB,3
       RETURN
       INCF    Key
       RLF     Mask,F                  ;Check next column
       DECFSZ  Counter,F
       GOTO    Scan_loop
       RETURN                          ;No keypress: Bit 4 from Key = 1.

Hans

1998\02\27@152404 by sdattalo

face
flavicon
face
Hans de Vries wrote:
>
> I've created (yet another) 4x4 matrix keyboard decode-routine.
> I've placed 4 NOP's in it, because in a similar routine, they also were
> there (bad reason) , but I'm not sure if they are needed.
> They are there to let the output-pins when the pattern on portb is
> changed. But are they nescessary?


There are several factors that affect this decision, however just
to be safe I would leave them in but change them to goto's:

{Quote hidden}

         goto    $+1                     ;Let pins settle
         goto    $+1                     ;But is this nescessary??
         goto    $+1
>         BTFSS   PORTB,0                 ;IS first bit clear?
>         RETURN                          ;Yes, so that row was pressed

So you get the same delay for half the instructions. Another trick
to get the 6-cycle delay is to do this:

>         MOVWF   PORTB                   ;Put mask on port
         CALL    a_return                ;Let pins settle
         goto    $+1                     ;But is this nescessary??

>         BTFSS   PORTB,0                 ;IS first bit clear?
a_return: RETURN                          ;Yes, so that row was pressed


If you have other delays then they can be grouped together:

delay_6:  NOP
delay_5:  NOP
delay_4:  RETURN

And then if you need a delay of 6 cycles, just add a 'CALL delay_6'
>         MOVWF   PORTB                   ;Put mask on port
         CALL    delay_6                 ;Let pins settle
                                         ;But is this nescessary??

>         BTFSS   PORTB,0                 ;IS first bit clear?
>         RETURN                          ;Yes, so that row was pressed




Payson posted something similar to this a good while back. Perhaps
you care to elaborate John?

Scott

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...