org 00
bcf status,rp1
bsf status,rp0 ;select memory bank 1
movlw B'00100000' ;set port A bits according to their function, ;1=input, 0=output
movwf trisa
movlw B'10001010'
movwf trisb ;also port B bits
movlw B'10010000'
movwf trisc ;and port C bits
movlw B'00000110'
movwf adcon1 ;set port A for digital i/o function
movlw D'249' ;sets PWM period. (alternative values can be used)
movwf pr2
bcf status,rp0 ;select bank 0
;set up PWM
movlw B'00000100' ;switch on Timer2, no pre or postscale
movwf t2con
movlw B'00001100' ;enable PWM
movwf ccp1con
movwf ccp2con
;set up SPI
movlw B'00110001'
movwf SSPCON
movlw B'00000000'
movwf SSPSTAT
;------------------------------------------------------------------
movlw 00
clrf porta
clrf portb
clrf portc
loop bsf porta,sipo_strobe
bcf porta,sipo_enable
call delay200
movlw B'10101010'
movwf sspbuf
call delay200
bcf porta,sipo_strobe
bsf porta,sipo_enable
call delay1000
bsf porta,sipo_strobe
bcf porta,sipo_enable
call delay200
movlw B'01010101'
movwf sspbuf
call delay200
bcf porta,sipo_strobe
bsf porta,sipo_enable
call delay1000
goto loop