Code:
'****************************************************************'* Name : UNTITLED.BAS *
'* Author : richard *
'* Notice : Copyright (c) 2022 caveat emptor *
'* : All Rights Reserved *
'* Date : 11/10/2022 *
'* Version : 1.0 *
'* Notes : *
'* : pic18f26k22 *
'****************************************************************
#CONFIG
CONFIG FOSC = INTIO67
CONFIG PLLCFG = ON
CONFIG PRICLKEN = ON
CONFIG FCMEN = OFF
CONFIG IESO = OFF
CONFIG PWRTEN = ON
CONFIG BOREN = SBORDIS
CONFIG BORV = 190
CONFIG WDTEN = OFF
CONFIG WDTPS = 32768
CONFIG CCP2MX = PORTC1
CONFIG PBADEN = OFF
CONFIG CCP3MX = PORTB5
CONFIG T3CMX = PORTC0
CONFIG HFOFST = ON
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
NumberOfDisplays CON 36
NumberOfRows CON 10
DEFINE OSC 64
DEFINE DEBUG_REG PORTB
DEFINE DEBUG_BIT 7
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
LATB.7=1
bcnt VAR BYTE bank0
dcnt VAR BYTE bank0
BUFF VAR BYTE[32]
iteration VAR word
OSCCON=$70
OSCTUNE.6=1
while ! osccon2.7 :WEND ;wait for pll
ANSELB=0
ANSELC=0
ANSELA=0
dspbuff var byte[380]
clear
trisc = %01111111
TRISB = %01111111
TRISA = %11111111
pause 1000
debug 13,10,"ready",13,10
LATc.7=0
;38x8 bits wide 10 bits high
main:
iteration=0
dspbuff[379]=3
dspbuff[37]=3
WHILE iteration<610
LATc.7=1
gosub rotate_l
LATc.7=0
debug 13,10,dec iteration
debug 13,10,bin8 dspbuff[379]," " ,bin8 dspbuff[378]," " ,bin8 dspbuff[343] ," ",bin8 dspbuff[342]
debug 13,10,bin8 dspbuff[37] ," " ,bin8 dspbuff[36] ," " ,bin8 dspbuff[1] ," ",bin8 dspbuff[0]
pause 50
iteration=iteration+1
WEND
iteration=0
dspbuff[379]=$c0
dspbuff[37]=$c0
WHILE iteration<610
LATc.7=1
gosub rotate_R
LATc.7=0
debug 13,10,dec iteration
debug 13,10,bin8 dspbuff[379]," " ,bin8 dspbuff[378]," " ,bin8 dspbuff[343] ," ",bin8 dspbuff[342]
debug 13,10,bin8 dspbuff[37] ," " ,bin8 dspbuff[36] ," " ,bin8 dspbuff[1] ," ",bin8 dspbuff[0]
pause 50
iteration=iteration+1
WEND
goto main
rotate_r: ' pic18
asm
banksel _bcnt ;ROW
movlw _NumberOfRows ;10 rows
movwf _bcnt
movlw high (_dspbuff) ;BOTTOM OF BUFFER
movwf FSR0H
movlw low (_dspbuff)
movwf FSR0L
movlw low((_NumberOfDisplays + 2)*_NumberOfRows-1) ;TOP OF BUFFER
ADDWF FSR0L
movlw high((_NumberOfDisplays + 2)*_NumberOfRows-1)
ADDWFC FSR0H
MOVLW _NumberOfDisplays + 2;36 displays + 2 outside of display
RROW
movwf _dcnt ;display
bcf STATUS, C
Rcol
rrcf POSTDEC0 ,f ;PER display
DECFSZ _dcnt ,F
BRA Rcol
BNC RBNC
bsf PLUSW0,7 ;max displays would be 127 to use plusw
RBNC
DECFSZ _bcnt ,F
BRA RROW
banksel 0
return
endasm
rotate_l: ' pic18
asm
banksel _bcnt ;ROW
movlw _NumberOfRows
movwf _bcnt
movlw high (_dspbuff) ;BOTTOM OF BUFFER
movwf FSR0H
movlw low (_dspbuff)
movwf FSR0L
LROW
MOVLW _NumberOfDisplays + 2;36 displays + 2 outside of display
movwf _dcnt ;display
comf WREG
incf WREG
bcf STATUS, C
Lcol
rlcf POSTINC0 ,f ;PER display
DECFSZ _dcnt ,F
BRA Lcol
BNC LBNC
bsf PLUSW0,0 ;max displays would be 127 to use plusw
LBNC
DECFSZ _bcnt ,F
BRA LROW
banksel 0
return
endasm
Bookmarks