Here is a copy of the Richards example.
Code:
'***************************************************************************
'* Name : ap102.pbp *
'* Author : richard *
'* Notice : *
'* : *
'* Date : 10/11/2017 *
'* Version : 1.0 *
'* Notes : only tested on pic18 @64 MHZ *
'* : pic18f26k22
'***************************************************************************
#CONFIG
CONFIG FOSC = INTIO67
CONFIG PLLCFG = ON
CONFIG PRICLKEN = OFF
CONFIG FCMEN = OFF
CONFIG IESO = OFF
CONFIG PWRTEN = OFF
CONFIG BOREN = SBORDIS
CONFIG BORV = 190
CONFIG WDTEN = ON
CONFIG WDTPS = 32768
CONFIG CCP2MX = PORTC1
CONFIG PBADEN = OFF
CONFIG CCP3MX = PORTB5
CONFIG HFOFST = ON
CONFIG T3CMX = PORTC0
CONFIG P2BMX = PORTB5
CONFIG MCLRE = EXTMCLR
CONFIG STVREN = ON
CONFIG LVP = OFF
CONFIG XINST = OFF
CONFIG DEBUG = OFF
CONFIG CP0 = OFF
CONFIG CP1 = OFF
CONFIG CP2 = OFF
CONFIG CP3 = OFF
CONFIG CPB = OFF
CONFIG CPD = OFF
CONFIG WRT0 = OFF
CONFIG WRT1 = OFF
CONFIG WRT2 = OFF
CONFIG WRT3 = OFF
CONFIG WRTC = OFF
CONFIG WRTB = OFF
CONFIG WRTD = OFF
CONFIG EBTR0 = OFF
CONFIG EBTR1 = OFF
CONFIG EBTR2 = OFF
CONFIG EBTR3 = OFF
CONFIG EBTRB = OFF
#ENDCONFIG
led_num con 3
pixels var byte[led_num * 3]
pallet var byte[21]
apa_global VAR byte bank0 ;global level 0-31
bit_cnt VAR byte bank0
i VAR byte
k VAR byte
j VAR byte
goto overpix
asm
_showpix
movlw LOW _pixels
movwf FSR2L
movlw high _pixels
movwf FSR2H
movlw 4
movwf _bit_cnt
movlw 0
s_frame ;start frame 4x 00 bytes
bcf PIR1,SSPIF
movwf SSPBUF
stspi BTFSs PIR1,SSPIF
bra stspi
decf _bit_cnt
bnz s_frame
movlw _led_num
movwf _bit_cnt
n_led
movlw 0xe0
iorwf _apa_global,W
bcf PIR1,SSPIF
movwf SSPBUF ;global led frame
glspi BTFSs PIR1,SSPIF
bra glspi
movf POSTINC2 ,W ;blue
bcf PIR1,SSPIF
movwf SSPBUF
blspi BTFSs PIR1,SSPIF
bra blspi
movf POSTINC2 ,W ;green
bcf PIR1,SSPIF
movwf SSPBUF
gnspi BTFSs PIR1,SSPIF
bra gnspi
movf POSTINC2 ,W ;red
bcf PIR1,SSPIF
movwf SSPBUF
rdspi BTFSs PIR1,SSPIF
bra rdspi
decf _bit_cnt
bnz n_led
movlw _led_num /8 +1 ;find magic number of bytes for stop frame
movwf _bit_cnt
movlw 0
stop_frame ;send stop frame
bcf PIR1,SSPIF
movwf SSPBUF
stopspi BTFSs PIR1,SSPIF
bra stopspi
decf _bit_cnt
bnz stop_frame
return
endasm
overpix:
define OSC 64
OSCCON = %11110000
ANSELb = 0
ANSELA = 0
ANSELC = 0
SSPCON1=$20;
SSPSTAT=$40;
trisc=%11010111
apa_global=1
latb.0=1
trisb=%11111110
arraywrite pallet,[255,0,0 ,0,255,0 ,0,0,255, 255,255,0 ,255,0,255 ,0,255,255, 255,255,255]
k=0 ;colour index
j=0
gosub shuffle
aloop:
call showpix
gosub shuffle
pause 40
goto aloop
And a YouTube video here
Ioannis
Bookmarks