OK, I've got one of these 7219s wired up, using your code (thank you). When I fire up the code though, all 6 displays simply show 8s. I read a post by TimV who had a similar problem but then lost the trace of how exactly it got fixed.
Here're my readings if you could have a quick check:
1. clk, load, din all swing to 4.85V on a HIGH command
2. all 3 are connected to ground via 15K resistors (I didn't have 10K)s like:
ground ------ 15K --------7219 pin
|
picaxe pin ----- 390R -----|
3. pins 4 and 9 of the 7219 are to 0V
4. pin 19 is to +5V with a 0.1uF cap to ground
5. pin 18 has 21K to +5V to set the segment current
6. output pin 7 on picaxe 28x = 7219 pin 12 (load)
7. output pin 3 on 28x = 7219 pin 3 (din)
8. output pin 0 on 28x = 7219 pin 13 (clk)
Here's my code (doesn't it look familiar!)
Maybe there's something in there that's not right? All help gratefully received....
Here're my readings if you could have a quick check:
1. clk, load, din all swing to 4.85V on a HIGH command
2. all 3 are connected to ground via 15K resistors (I didn't have 10K)s like:
ground ------ 15K --------7219 pin
|
picaxe pin ----- 390R -----|
3. pins 4 and 9 of the 7219 are to 0V
4. pin 19 is to +5V with a 0.1uF cap to ground
5. pin 18 has 21K to +5V to set the segment current
6. output pin 7 on picaxe 28x = 7219 pin 12 (load)
7. output pin 3 on 28x = 7219 pin 3 (din)
8. output pin 0 on 28x = 7219 pin 13 (clk)
Here's my code (doesn't it look familiar!)
Maybe there's something in there that's not right? All help gratefully received....
Code:
symbol load_7219 = 7 ' MAX7219 load pin
symbol clk_7219 = 0 ' MAX7219 clk pin
symbol din_7219 = 3 ' MAX7219 din pin
symbol calc = b13 ' general purpose calc variable
symbol other = b12 ' other variable for general purpose
symbol temp1 = w5 ' general purpose WORD calc variable 1
symbol temp2 = w4 ' general purpose WORD calc variable 2
symbol temp3 = w3 ' general purpose WORD calc variable 3
'MAX7219 registers
symbol DECODE_MODE = $09
symbol INTENSITY = $0A
symbol SCAN_LIMIT = $0B
symbol SHUTDOWN = $0C
symbol DIGIT_TEST = $0F
'MAX7219 values
symbol DIGIT_TEST_OFF = $00
symbol DIGIT_TEST_ON = $01
symbol DIGIT_1 = $01
symbol DIGIT_2 = $02
symbol DIGIT_3 = $03
symbol DIGIT_4 = $04
symbol DIGIT_5 = $05
symbol DIGIT_6 = $06
' basically b2, b12, b13 can be used for general calcs
' ***************************************************************************************************
' Boot up the MAX7219
' ***************************************************************************************************
start_7219:
pause 1000
b0 = DECODE_MODE
b1 = $FF ' code B decode for all digits
gosub send_data_7219
b0 = SCAN_LIMIT
b1 = $05 ' display digits 0 to 5
gosub send_data_7219
b0 = INTENSITY
b1 = $08 ' 17/32 intensity
gosub send_data_7219
b0 = SHUTDOWN
b1 = $01 ' normal operation
gosub send_data_7219
'Set test digit mode...
b0 = DIGIT_TEST
b1 = DIGIT_TEST_ON
gosub send_data_7219
'...wait for 1 sec...
pause 1000
'...then turn off test digit mode
b0 = DIGIT_TEST
b1 = DIGIT_TEST_OFF
gosub send_data_7219
loopy:
temp3 = 123
temp2 = 789
gosub display
wait 5
goto loopy
' ***************************************************************************************************
' WRITE DATA TO THE 7219 DISPLAY
' ***************************************************************************************************
display:
' temp = digits 5, 4, 3 i.e. 2, 5, 3 in 25.3 deg C
'read temperature first
' digit 5
calc = 0
b0 = DIGIT_6
b1 = temp3 // 100 ' divide temp into 100s
calc = b1 * 10 ' keep a running total
gosub send_data_7219
' digit 4
b0 = DIGIT_5
b1 = temp3 // 10 ' divide temp into 10s
calc = calc + b1 ' keep a running total
gosub send_data_7219
' digit 3
b0 = DIGIT_4
b1 = temp3 % calc ' subtract 100s and 10s from temp e.g. 253 - 250
gosub send_data_7219
' digit 2
calc = 0
b0 = DIGIT_3
b1 = temp2 // 100
calc = b1 * 10
gosub send_data_7219
' digit 1
calc = 0
b0 = DIGIT_2
b1 = temp2 // 10
calc = calc + b1
gosub send_data_7219
' digit 0
b0 = DIGIT_1
b1 = temp2 % calc ' subtract 10s e.g. 37 - 30 = 7
gosub send_data_7219
return ' display finished
' ***************************************************************************************************
' write data out to 7219 IC
' ***************************************************************************************************
send_data_7219:
low load_7219
pin3 = bit15
pulsout CLK_7219,1
pin3 = bit14
pulsout CLK_7219,1
pin3 = bit13
pulsout CLK_7219,1
pin3 = bit12
pulsout CLK_7219,1
pin3 = bit11
pulsout CLK_7219,1
pin3 = bit10
pulsout CLK_7219,1
pin3 = bit9
pulsout CLK_7219,1
pin3 = bit8
pulsout CLK_7219,1
pin3 = bit7
pulsout CLK_7219,1
pin3 = bit6
pulsout CLK_7219,1
pin3 = bit5
pulsout CLK_7219,1
pin3 = bit4
pulsout CLK_7219,1
pin3 = bit3
pulsout CLK_7219,1
pin3 = bit2
pulsout CLK_7219,1
pin3 = bit1
pulsout CLK_7219,1
pin3 = bit0
pulsout CLK_7219,1
high load_7219
return
Last edited: