Code:
' *****************************************************************************
' * *
' * File...... 8722 Segments Daisey chained displays with MAX7219 *
' * Purpose... PIC18F8722 on BIGPIC5 *
' * Date...... July 2009 *
' * *
' *****************************************************************************
' 1. PIC18F8722 on BIGPIC5 @ 40 MHz
' 2. Three display boards each with 8 digits controlled by MAX7219 drivers
' 3. All displays daisy-chained (Data_out to Data_in) on PORTE
define OSC 40 ' Define Xtal as 20 MHz, use "HSPLL" for programming
include "modedefs.bas" ' Include serout defines
Z var word
I var byte
DataPin var PORTE.0 ' For ETT display
ClockPin var PORTE.2 ' For ETT display
Load var PORTE.1 ' For ETT display
ADCON1 = %00001111 ' All ports digital
CMCON = $07 ' Comparators OFF
INTCON = $80 ' Turns off interrupts. See PBP page 187
TRISA=0 : TRISB=0 : TRISC=0 : TRISD=0 : TRISE=0 : TRISF=0 : TRISG=0 : TRISH=0 : TRISJ=0
PORTA=0 : PORTB=0 : PORTC=0 : PORTD=0 : PORTE=0 : PORTF=0 : PORTG=0 : PORTH=0 : PORTJ=0
' Clear displays:
low load
shiftout datapin,clockpin,1,[$0F, $00] ' 3rd Display Test mode off
shiftout datapin,clockpin,1,[$0F, $00] ' 2nd Display Test mode off
shiftout datapin,clockpin,1,[$0F, $00] ' 1st Display Test mode off
high load
low load
shiftout datapin,clockpin,1,[$09, $FF] ' Decode register - decode all 8 digits
shiftout datapin,clockpin,1,[$09, $FF] ' Decode register - decode all 8 digits
shiftout datapin,clockpin,1,[$09, $FF] ' Decode register - decode all 8 digits
high load
low load
shiftout datapin,clockpin,1,[$0A, $0F] ' Intensity register - 32/32 brightness
shiftout datapin,clockpin,1,[$0A, $0F] ' Intensity register - 32/32 brightness
shiftout datapin,clockpin,1,[$0A, $0F] ' Intensity register - 32/32 brightness
high load
low load
shiftout datapin,clockpin,1,[$0B, $07] ' Scan limit register - display all digits
shiftout datapin,clockpin,1,[$0B, $07] ' Scan limit register - display all digits
shiftout datapin,clockpin,1,[$0B, $07] ' Scan limit register - display all digits
high load
low load
shiftout datapin,clockpin,1,[$0C, $01] ' Shutdown register - normal operation
shiftout datapin,clockpin,1,[$0C, $01] ' Shutdown register - normal operation
shiftout datapin,clockpin,1,[$0C, $01] ' Shutdown register - normal operation
high load
for i=1 to 8
low load
shiftout datapin,clockpin,1,[i, $0F] ' Clear all digits
shiftout datapin,clockpin,1,[i, $0F] ' Clear all digits
shiftout datapin,clockpin,1,[i, $0F] ' Clear all digits
high load
next I
' *****************************************************************************
' * *
' * MAIN *
' * *
' *****************************************************************************
Main:
for Z= 0 to 64000
for I=0 to 4
low load
shiftout datapin,clockpin,1,[I+1,Z dig I] ' 3rd Display
shiftout datapin,clockpin,1,[I+1,Z dig I] ' 2nd Display
shiftout datapin,clockpin,1,[I+1,Z DIG I] ' 1st Display
high load
next I
pause 300
next Z
for i=1 to 8
low load
shiftout datapin,clockpin,1,[i,$F] ' Clear all digits
shiftout datapin,clockpin,1,[i,$F] ' Clear all digits
shiftout datapin,clockpin,1,[i,$F] ' Clear all digits
high load
next I
goto main
end
Bookmarks