PDA

View Full Version : Max7219 question



jamied
- 27th December 2008, 20:23
HI list, I have a small problem with a max7219 I was hoping to get some help with.
I have 8 led's connected to dig0 as the common and segments a-g and the decimal point connected to individual leds not a 7 segment display.

All I'm trying to do is count from 0 to 255 in binary on the leds so I can learn the chip. It counts properly but doesn't shut off leds while it counts. for example at 0 all led's are off. at 1 d0 is on but when it gets to 2 it turns on d1 and keeps d0 on also. displaying the number 3.... as it goes from 2,4,8,16,32 ect I can see the next power led turn on but it's not turning the others off while counting. kind of latching the values.
I would expect that when sending the number 8 to it that d3 would be on and d2,d1,d0 would be off ect. but they stay on. showing 15

Could someone pls look at my code and point me in the right direction?

everything else works ok on it.
I'm just posting the problem section, all variable setups and port assignments are ok

Thank you



dig0 var word
cr var byte



Mainloop:
Dig0 = $0100 'select digit 0

GoSub DecodeMode
GoSub ShutDownMode
GoSub ScanLimit
GoSub Intensity

Disp:Dig0 = $0100 'select digit 0

For CR=0 To 255
Dig0 = Dig0 | CR
Low Load
DelayMS 1
shiftout Dout,Clk,msbfirst,[Dig0\16] 'no decode
DelayMS 1
High Load
DelayMS 200
Next
GoTo Disp




DecodeMode:
Low Load
shiftout Dout,Clk,msbfirst,[$0900\16] 'no decode
High Load
Return

ShutDownMode:
Low Load
shiftout Dout,Clk,msbfirst,[$0C01\16] '$0C is shut down mode register and $01 = on $00 = off
High Load
Return


ScanLimit:
Low Load
Shiftout Dout,Clk,msbfirst,[$0B00\16] '$0B scan limit register(#of led lines) we have only one so Dig 0
High Load
Return


Intensity:
Low Load
Shiftout Dout,Clk,msbfirst,[$0A09\16] '$0A intensity register $00 is min and $0F is max
High Load
Return

mackrackit
- 28th December 2008, 13:14
I have not used this chip but this may held.
www.ezl.com/~rsch/MAX7219-21%208-Digit%20LED%20Display%20Driver.pdf

Darrel Taylor
- 28th December 2008, 20:53
...All I'm trying to do is count from 0 to 255 in binary on the leds so I can learn the chip. It counts properly but doesn't shut off leds while it counts.

By ORing Dig0 with CR, it keeps any bits that were already in the variable.

For CR=0 To 255
Dig0 = Dig0 | CR
Low Load
DelayMS 1
shiftout Dout,Clk,msbfirst,[Dig0\16] 'no decode
DelayMS 1
High Load
DelayMS 200
Next

Might work better with Dig0 as the FOR variable, and skip the OR.

And it looks like you are using PROTON basic.
They have a PROTON forum here ...
http://www.picbasic.org/forum
<br>

jamied
- 29th December 2008, 15:37
Getting rid of the OR solved it!! Thank you.
I had to do some digging to find out that the pipe was an OR

Thanks again!


Jamie

mackrackit
- 29th December 2008, 16:33
Getting rid of the OR solved it!! Thank you.
I had to do some digging to find out that the pipe was an OR

Thanks again!


Jamie

Not sure where you did you digging, but the Math Operators section in the Pic Basic manual has all kinds of things to dig in :)