I'm lost on how to procede from here.. any help will be appreciated...
Code: Select all
Device = 18F25k22
Clock = 32
Config
FOSC = INTIO67, // HS Oscillator
FCMEN = OFF, // Failsafe Clock Monitor Disabled
IESO = OFF, // Int/Ext Oscillator Switch Over Disabled
PWRTEN = OFF, // Power Up Timer Disabled
BOREN = OFF, // Brownout Reset Disabled
BORV = 250,
WDTEN = OFF, // Watchdog Timer Disabled
MCLRE = EXTMCLR, // MCLR Enabled
WDTPS = 256, // 15000 x 4mS = 60 seconds
LVP = OFF, // Low_Voltage Programming
PBADEN = OFF, // PORTB Digital
CCP2MX = PORTC1,
CP0 = OFF,
CP1 = OFF,
CP2 = OFF,
CP3 = OFF,
CPB = OFF,
CPD = OFF
Include "Timer0.bas"
' I/O setting
Dim PA As PORTA.0
Dim PB As PORTA.1
Dim PC As PORTA.2
Dim PD As PORTA.3
Dim R1 As PORTB.0
Dim G1 As PORTB.1
Dim B1 As PORTB.2
Dim R2 As PORTB.3
Dim G2 As PORTB.4
Dim B2 As PORTB.5
Dim CLK As PORTC.0
Dim LAT As PORTC.1
Dim OE As PORTC.2
Dim Led1 As PORTC.4
Dim Led2 As PORTC.5
' Ram Allocation
Dim BUF(513) As Byte
Dim A,B As Byte
Dim C As Byte
Dim Addr As Byte
' The RGB Matrix has 2 blocks of 16 lines each
' the First block (lines 0 to 15) uses Dalta Lines R1, G1 B1
' the Second block (lines 16 to 31) uses Dalta Lines R2, G2 B2
' PortA bits 0..3 selects the line to shift
Event Refresh()
Dim x As Byte
OE=1
PORTA=Addr
For x=0 To 31
R1=BUF(Addr*32+x).0
G1=BUF(Addr*32+x).1
B1=BUF(Addr*32+x).2
R2=BUF(Addr*32+x).4
G2=BUF(Addr*32+x).5
B2=BUF(Addr*32+x).6
CLK=1
CLK=0
Next
LAT=1
LAT=0
Inc(Addr)
If Addr>15 Then
Addr=0
EndIf
OE=0
End Event
Interrupt ISR()
If Timer0.InterruptFlag =1 Then
Timer0.SInterrupt()
EndIf
End Interrupt
' BUF(0..512) Memory Organization:
' Each byte corresponds to 2 pixels
' nibble0 for first block, nibble1 for second block
Sub SetPixel(x,y,d As Byte)
Dim fdat As Byte
' Timer0.Disabled()
If y<16 Then
fdat=d And $0f
BUF(y*32+x)=BUF(y*32+x) And $F0
BUF(y*32+x)=BUF(y*32+x) Or fdat
Else
fdat=d<<4
BUF((y-16)*32+x)=BUF((y-16)*32+x) And $0F
BUF((y-16)*32+x)=BUF((y-16)*32+x) Or fdat
EndIf
' Timer0.Enabled()
End Sub
Sub InitHardware()
OSCCON=$60
OSCTUNE.6=1
CM1CON0=0
CM2CON0=0
ADCON0=0
ADCON1= $0F
ADCON2=0
ANSELA=0
ANSELB=0
ANSELC=0
Output(Led1)
Output(Led2)
Output(CLK)
Output(LAT)
Output(OE)
Output(R1)
Output(G1)
Output(B1)
Output(R2)
Output(G2)
Output(B2)
Output(PA)
Output(PB)
Output(PC)
Output(PD)
PA=0
PB=0
PC=0
PD=0
R1=0
G1=0
B1=0
R2=0
G2=0
B2=0
CLK=0
LAT=0
OE=0
Timer0.Initialize(Refresh)
Timer0.SetPrescaler(Timer0.PS32) 'Timer0.PS2 99=prescaler disabled
Timer0.EightBit = 1
Timer0.Preload= 10
Timer0.EnableInterrupt()
Enable(ISR)
End Sub
''''''''''
' MAIN
''''''''''
InitHardware()
Addr=0
Clear(BUF)
Timer0.Enabled()
C=1
Repeat
For A=0 To 31
For B=0 To 31
SetPixel(A,B,C)
Next
DelayMS(10)
Next
Inc(C)
If C>7 Then
C=0
EndIf
Until false