Andres Rodriguez
New Member
Hardware and software work as expected for about 10 to 30 minutes then the segments start turning on and off in a random fashion and eventually they turn off. Removing the power and reconnecting immediately does not work. But after waiting for about 30 minutes, if I reconnect, it works again. I cannot detect overheating (touching the ICs).
Code:
' DIRECTIVES
#picaxe 20X2 ' specify the PICAXE processor
#no_data ' speed up the download
#no_table ' speed up the download
#terminal off ' disable terminal window
' PIN ASSIGNEMENTS
Symbol load = C.2 ' briefly pulse C.2 to transfer data to LEDs
Symbol But = B.0
Symbol SW = B.2
Symbol LED = B.6
Symbol Counter = W0
Symbol Valones = b2
Symbol Valtens = b3
Symbol Valhund = b4
b5=0
Counter=1
' Register addresses for the MAX7219
symbol decode = 9 ' decode register; specify digits to decode
symbol brite = 10 ' intensity (brightness) register; 15 = 100%
symbol scan = 11 ' scan-limit register; specify how many digits
symbol on_off = 12 ' 1 = display on; 0 = display off
' ============================= Begin Main Program =============================
setfreq m64
dirsb = %11111010 ' set portB as all outputs (except B.0 and B.2)
dirsc = %10111111 ' set portC as outputs (except C.6)
hspisetup spimode00,spifast ' set up hspi
' Initialize MAX7219
hspiout (scan,3) ' set scan limit for digits 0-3
pulsout load,1
hspiout (brite,5) ' set brightness to 5 (15 = 100%)
pulsout load,1
hspiout (decode,15) ' set BCD decoding for digits 0-3
pulsout load,1
hspiout (on_off,1) ' turn display on
pulsout load,1
Calc:
Valhund=counter/100
If Valhund=0 then Let Valhund=15
endif
Valtens=counter//100
Valtens=Valtens/10
If Valtens=0 then let Valtens=15
endif
Valones=Counter//100
Valones=Valones//10
' Send data to the four digits
Display:
hspiout (1,15) ' 1st LED from left
pulsout load,1
hspiout (2,Valhund) ' 2nd LED from left
pulsout load,1
hspiout (3,Valtens) ' 3rd LED from left
pulsout load,1
hspiout (4,Valones) ' 4th LED from left
pulsout load,1
Pause 500
Sig:
button B.0,1,254,254,b5,1,pushed
If PinB.2=0 then High B.6 else Low B.6
endif
Pause 5000
Goto Sig
Pushed:
If PinB.2=0 then Decr
Counter=Counter+1
Goto Calc
Decr:
Counter=Counter-1
Goto Calc
Attachments
-
45.1 KB Views: 66