Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 0.58 KB | None | 0 0
  1. SENDREG     EQU     0x20
  2. BITCOUNT    EQU     0x21
  3.  
  4. #define     SDO     PORTB,0
  5. #define     SCK     PORTB,1
  6. #define     LAT     PORTB,2
  7.  
  8.  
  9.  
  10. SerOut      movwf       SENDREG     ;load data to be sent into sendreg
  11.         movlw       0x08        ;init bit counter
  12.         movwf       BITCOUNT
  13.         bsf     SDO     ;default MSB=1
  14.         btfss       SENDREG,7   ;does MSB=1?
  15.         bcf     SDO     ;no, send 0
  16.         bsf     SCK     ;pulse clock
  17.         bcf     SCK
  18.         rlf     SENDREG,F   ;shift bits
  19.         decfsz      BITCOUNT,F  ;decrement bit counter
  20.         goto        $-7     ;continue sending until bit counter = 0
  21.         bsf     LAT     ;all 8 bits sent, pulse latch
  22.         bcf     LAT     ;all lines low
  23.         bcf     SCK
  24.         bcf     SDO
  25.         return              ;done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement