PIC Microcontoller IO Method

High speed serial IO pin sampleing

by Scott Dattalo

to sample a stream as fast as possible. For an
arbitrary length (but constrained by the PIC's memory) arrary of bits, you can
do something like:


     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,0
     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,1
     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,2
     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,3
     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,4
     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,5
     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,6
     btfsc   BIT_PORT,THE_BIT
      bsf    byte0,7


     btfsc   BIT_PORT,THE_BIT
      bsf    byte1,0

etc, for byte1, byte2 This'll give 2-cycle sampling per bit. There's a way to improve this to 1-cycle resolution, but you're limited to 16 bits.

Dmitry Kiryashov [zews at AHA.RU] says:

...it will make all the port unusable for other purposes ;) Source is located in bit.0 for instance. tris.0 is input others for output. Probably will not work on very fast speed (Scenix?)
        rlf     port,F  ;do it 7 times

        rlf     port,W  ;get 8 samples into W

        rlf     port,F  ;do it 8 times
                        ;will have one more 8 samples
                        ;in carry,port.7..1

also: PIC Microcontoller Bit Math Method Shifting long strings of bits

See:

Comments: