Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 0.58 KB | None | 0 0
  1. #define     SDO     PORTA,0
  2. #define     SCK     PORTA,1
  3. #define     CS      PORTA,2
  4.  
  5. SEND        EQU     0x20
  6.  
  7. SPISend     bcf     CS          ;chip select lo
  8.         movlw       0x08            ;initialize bit counter
  9.         movwf       BITCOUNT
  10.  
  11.         btfss       SEND,7          ;is MSB in send register high?
  12.         goto        SendLow         ;no, send 0
  13.  
  14. SendHigh    bsf     SDO         ;send 1
  15.         goto        Shift
  16.  
  17. SendLow     bcf     SDO         ;send 0
  18.         goto        Shift
  19.  
  20. Shift       bsf     SCK         ;pulse clock
  21.         bcf     SCK
  22.         rlf     SEND,F          ;shift bits to the left
  23.         decfsz      BITCOUNT,F      ;decrement bit counter
  24.         goto        $-10            ;loop back if bit counter > 0
  25.         bsf     CS          ;bit counter = 0, chip select hi
  26.         return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement