here is the complete code. I added the config BOREN = off and looks like it fixed the freezing up issue.
Thanks for looking at it. I need to research what Boren is, something to do with low operating voltage??
Code: Select all
' 8x8 RG Matrix Scrolling text test
' PORTB = RED LED Cathodes
' PORTB = GREEN LED Cathodes
' PORTC = Anodes
DEVICE = 18F24K20 ' Tell the compiler what chip we are using
CLOCK = 8 ' Tell the compiler what we will be setting the clock to (in Mhz)
CONFIG MCLRE = OFF
CONFIG FOSC = intio67 ' Internal oscillator, IO on pins 6 and 7
CONFIG BOREN = OFF
INCLUDE "utils.bas"
CONST RedData(112) AS BYTE = (%00110111,%01000000,%00100000,%01000000,%00110111,%00000000,%01110111,%01010100,
%01000010,%00000000,%01110111,%01000001,%01110010,%00000100,%00000000,%01111110,
%01000001,%01110001,%00000010,%00000100,%00000000,%01100000,%00010000,%00000111,
%00010000,%01100000,%00000000,%00000000,%00000000,%01110111,%01000100,%01000100,
%00000000,%01110111,%00010000,%00010000,%01110111,%00000000,%01110111,%01000001,
%00110010,%00000100,%00000000,%01110111,%00000000,%01110100,%01010100,%01010111,
%00000000,%01000000,%01000000,%01110111,%01000000,%01000000,%00000000,%00110111,
%01000000,%01000000,%00100000,%01000000,%01110111,%00000000,%00110111,%01010000,
%01010000,%01110111,%00000000,%01110100,%01010100,%01010111,%00000000,%00000000,// custom
%01110111,%01010100,%01000100,%00000000,%01110111,%00000100,%00000100,%00000000,
%01110111,%01010100,%01000100,%00000000,%01110111,%01000100,%01000100,%00000000,
%01110111,%01000001,%01110010,%00000100,%00000000,%00110011,%01000100,%01000100,
%00110010,%00000000,%01110111,%00000100,%00000011,%00000100,%01110111,%00000000,
%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000)
''CONST GreenData(105) AS BYTE = (%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111100,%10000010,%10000010,%01000100,%00000000,%11111110,%00010000,%00010000,%11111110,%00000000,%11111110,%00010010,%00010010,%11101100,%00000000,%10000010,%11111110,%10000010,%00000000,%01001100,%10010010,%10010010,%01100100,%00000000,%00000010,%11111110,%00000010,%00000000,%11111110,%00000100,%00011000,%00000100,%11111110,%00000000,%11111100,%00010010,%11111100,%00000000,%01001100,%10010010,%10010010,%01100100,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000)
DIM RedLEDs AS PORTb
DIM GreenLEDs AS PORTa
DIM Anodes AS PORTC
DIM GreenBuffer(8) AS BYTE
DIM RedBuffer(8) AS BYTE
DIM x AS BYTE
DIM ScrollingTextOffset AS WORD
DIM ScrollingTextSpeed AS BYTE
DIM DefaultScrollingTextSpeed AS BYTE
SUB UpdateScrollingText()
IF ScrollingTextSpeed <> 0 THEN
DEC(ScrollingTextSpeed)
ELSE
ScrollingTextSpeed = DefaultScrollingTextSpeed
INC(ScrollingTextOffset)
IF ScrollingTextOffset >= (BOUND(RedData)-7) THEN ' we need to check if we have reached the start of the last eight columns of data that's why we take away 8
ScrollingTextOffset = 0
ENDIF
ENDIF
END SUB
SUB SaveGraphics()
FOR x = 0 TO 7
''GreenBuffer(x) = GreenData(x + ScrollingTextOffset)
RedBuffer(x) = RedData(x + ScrollingTextOffset)
NEXT
END SUB
SUB DisplayGraphics()
FOR x = 0 TO 7
''GreenLEDs = GreenBuffer(x) XOR %11111111
RedLEDs = RedBuffer(x) XOR %11111111
Anodes.bits(7 - x) = 1
DELAYus(520)
Anodes.bits(7 - x) = 0
NEXT
END SUB
SetAllDigital
TRISA = %00000000 ' PORTA outputs
TRISB = %00000000 ' PORTB outputs
TRISC = %00000000 ' PORTC outputs
'TRISD = %00000000 ' PORTC outputs
'TRISE = %00000001 ' PORTC outputs except pin 0
// Start Of Program
OSCCON = %01100000 ' Internal oscillator running at 8mHz
'OSCTUNE.bits(6) = 1 ' enable PLL so we can run this thing at 32Mhz
//GreenLEDs = %00000000 ' we will be xor'ing the led data to make sure it sends logic 0's to turn on the LED
RedLEDs = %00000000 ' we will be xor'ing the led data to make sure it sends logic 0's to turn on the LED
Anodes = %00000000
ScrollingTextOffset = 0
DefaultScrollingTextSpeed = 45
ScrollingTextSpeed = DefaultScrollingTextSpeed
// Main Loop
WHILE True() // This creates an infinite loop
UpdateScrollingText
SaveGraphics
DisplayGraphics
'for x = 0 to 7
'RedBuffer(x)= %00000000
'next
'DefaultScrollingTextSpeed = 45
'ScrollingTextSpeed = DefaultScrollingTextSpeed
WEND // Loop back to the while loop as long as we havent finished.