7219 question for Martin!

nbw

Senior Member
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....

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:

nbw

Senior Member
Just in case anyone asks - my poor ASCII art makes it look as though I have wired the picaxe pin straight to ground... I haven't. One end of the 390R resistor goes to the 7219 pin, the other end to the picaxe pin.
 

westaust55

Moderator
Could you possibly go back to your first post and add the ['code] and ['/code] markers around your program code as highly recommended in the Readme First post at the beginning of this forum.
See here: http://www.picaxeforum.co.uk/showthread.php?t=7679

It will stop your post being a figurative mile long but those who want to read it still can do so.

thanks
 
Last edited:

nbw

Senior Member
Hi there Westaust, yes - that was the thread I was reading. It looked by page 2 that the 7219 problems had been resolved (I couldn't quite make out how- that's where I was 'lost') and then the thread went on to talk about DS1307 and other aspects of the clock-making.

I seem to have my 7219 at a similar point - all 3 interface lines tied to ground through 10+K resistors, getting nice 5V when they go high, all display segments lighting up ok for all digits.

The only 2 things I can think of is 1, I've errored the code somehow or 2, maybe those 390 resistors between the 7219 and picaxe are causing problems?
 

westaust55

Moderator
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)
Okay it may be a typo above but at item 7, it should be:
7. output pin 3 on 28x = 7219 pin 1 (din)

Sorry I do not have time at the moment to go right thru your code.
 

nbw

Senior Member
Hi WestAust, yes - that was a typo. I definitely have pin 1 of the 7219 wired as DIN.
 

nbw

Senior Member
Hmm. Rechecking the datasheets. I see on page 12 Maxim have added 4.7k resistors between each common cathode and the 5V line. They have a footnote suggesting that the '*' resistors are for the MAX7221 only, so I'm wondering about those 4.7K resistors.

Martin/Tim/et al: have you used these resistors on your 7219 set-ups?

thanks for your thoughts

p.s. rechecked my wiring - looks ok... still wondering if I need the 390R from picaxe outpin to 7219 load/din/clk, or whether that is adding to the problems...
 

nbw

Senior Member
As far as I can understand from the 7219 datasheet also, the 'Test mode' will light all segments for all digits and high brightness (31/32 intensity). This seems to be what's happening (and only that) - my 6 digits shows 8s, nice and bright. I used about 20K of Iset resistance, from memory.

I don't know if somehow the 7219 is getting stuck in the test mode? Before I had the 3 x 15K resistors tying the interface pins to 0V I would occasionally get some digit blanking with the odd non-sensical segment lighting up here and there before reverting to 6x 8s.
 
Top