Code:
'======= FUSES ====================================================================================
' PIC 16F690
' Internal oscillator (activate OSCCON register)
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
@ ERRORLEVEL -306
@ ERRORLEVEL -202
' ====== REGISTERS ==================================================================================
' 76543210
OPTION_REG = %10000000 'PORT A&B Pull-Ups disabled (look WPUA & WPUB)
OSCCON = %01110000 'Internal RC set to 8Mhz
ANSEL = %00000000 'Analog inputs Channels 0 to 7
ANSELH = %00000000 'Analog inputs Channels 8 to 11
WPUA = %00000000 'Weak pull-ups
WPUB = %00000000 'Weak pull-ups
ADCON0 = %00000000 'A/D Module (OFF)
CM1CON0 = %00000000 'Comparator1 Module (OFF)
CM2CON0 = %00000000 'Comparator2 Module (OFF)
INTCON = %00000000 'INTerrupts CONtrol
TRISA = %00000000 'Set Input/Output (0 to 5)
PORTA = %00000000 'Ports High/Low (0 to 5)
TRISB = %00000000 'Set Input/Output (4 to 7)
PORTB = %00000000 'Ports High/Low (4 to 7)
TRISC = %00000000 'Set Input/Output (0 to 7)
PORTC = %00000000 'Ports High/Low (0 to 7)
' ====== DEFINES ==================================================================================
DEFINE OSC 8
DEFINE NO_CLRWDT 1
' ====== VARIABLES ================================================================================
Addr_Reg VAR BYTE ' 7219's address register (1..8)
Data_Reg VAR BYTE ' 7219's data register
ScrollSpeed VAR WORD ' pause time between frames (8 lines = 1 frame)
Line VAR BYTE ' line number of a frame - from 0 (bottom line) to 7 (top line)
Start VAR BYTE ' starting position in LOOKUP
CLK VAR PORTB.4 ' connected to module's CLK
LOAD VAR PORTB.5 ' connected to module's CS
DAT VAR PORTB.6 ' connected to module's DIN
' ====== INITIALIZE ===============================================================================
LOW CLK
LOW DAT
LOW LOAD
ScrollSpeed = 80
' ====== MAX7219 SETUP ============================================================================
Addr_Reg = $09 : Data_Reg = $00 : GOSUB MaxWrite ' DECODE-MODE (= BCD), NO DECODE
Addr_Reg = $0A : Data_Reg = $00 : GOSUB MaxWrite ' LEDS INTENSITY MIN=0, MAX=F
Addr_Reg = $0B : Data_Reg = $07 : GOSUB MaxWrite ' NUMBER OF DISPLAYED LINES (0=bottom .. 7=top)
Addr_Reg = $0C : Data_Reg = $01 : GOSUB MaxWrite ' SHUTDOWN=0, NORMAL OPERATION=1
Addr_Reg = $0F : Data_Reg = $00 : GOSUB MaxWrite ' DISPLAY-TEST (0=OFF, 1=ON)
' ====== PROGRAM ==================================================================================
SCROLL:
FOR Start = 0 TO 80 ' number of data in the LOOKUP - 8
FOR Addr_Reg = 1 TO 8
Line = (Addr_Reg - 1) + Start
GOSUB PICBasic
GOSUB MAXWRITE
NEXT
PAUSE ScrollSpeed
NEXT
GOTO SCROLL
END
' ====== SUBROUTINES ==============================================================================
MaxWrite:
SHIFTOUT DAT,CLK,1,[Addr_Reg,Data_Reg] ' send the data to the MAX7219
PULSOUT LOAD,1 ' push the data into the MAX7219
RETURN
' ====== DISPLAY DATA =============================================================================
' 90 degrees anticlockwise rotated characters for use with vertically positionned MAX7219 ARDUINO module
'Right_V_Line:
'LOOKUP Line, [ 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 0, 0, 0, 0],Data_Reg
PICBasic:
LOOKUP Line, [ 0, 0, 0, 0, 0, 0, 0, 0,_
0,254,254, 34, 34, 62, 28, 0,_ 'P
0, 0,130,254,254,130, 0, 0,_ 'I
0,124,254,130,130,198, 68, 0,_ 'C
0, 0, 0, 0, 0, 0, 0, 0,_
0,254,254,146,146,254,108, 0,_ 'B
0, 64,232,168,168,248,240, 0,_ 'a
0,144,168,168,168,168, 72, 0,_ 's
0, 0,128,244,244,128, 0, 0,_ 'i
0,112,248,136,136,216, 80, 0,_ 'c
0, 0, 0, 0, 0, 0, 0, 0],Data_Reg
RETURN
Bookmarks