list p = 18f1320 #include p18f1320.inc config OSC = INTIO2 config BOR = ON config BORV = 20 config MCLRE = ON config LVP = OFF org 0x0000 goto _Reset org 0x0008 goto _High org 0x0018 goto _Reset _High org 0x002A _Reset movlw 0x63 ; 4MHz internal oscillator movwf OSCCON setf ADCON1 ; analog pins to digital clrf PORTA ; all pins to 0 clrf PORTB clrf TRISA ; all pins but RB0 as output clrf TRISB bsf TRISB,RB0 movlw 0x0D ; number of bytes in 0x00 movwf 0x00 movlw 0x02 ; location of data in 0x01 movwf 0x01 movlw 0x0D ; the data itself in 0x02 through 0x0F lfsr 0x02 load movwf POSTINC0 decfsz WREG,W goto load call Send ; send the data endLoop goto endLoop Send movlb 0x00 ; select bank 0 lfsr FSR0,0x00 ; load pointer to data movf 0x01,W movwf FSR0L sendByteLoop movlw 0x01 ; set the bit mask movwf 0x01 ; store the bit mask sendBitLoop andwf INDF0,W ; AND data with bit mask bcf PORTB,RB1 ; set the pin for the bit value tstfsz WREG bsf PORTB,RB1 bsf PORTB,RB2 ; set clock high ]-+- toggle clock rlcf 0x01,F ; shift the bit mask | movf 0x01,W ; | bcf PORTB,RB2 ; set clock low ]-+ bnc sendBitLoop ; loop if not done with byte incf FSR0L,F ; increment pointer decfsz 0x00,F ; more bytes? goto sendByteLoop ; yep! return ; nope, all done! end