PDA

View Full Version : Using MAX 7221 LED driver


Nick
- 24th February 2005, 01:29
Hi all,

Can anyone point me to some code samples on how to interface MAX 7221
with a PIC microcontroller to be able to control 64 LEDs in non-decode mode?
I need to know how to initialize the 7221, how to access each one of the
64 LEDs and the steps to refresh the output.

mister_e
- 24th February 2005, 13:31
Look this thread with a Max7219... suppose to be handy enough (http://www.picbasic.co.uk/forum/showthread.php?t=879&highlight=tach%2A+max%2A)

Nick
- 24th February 2005, 23:27
Thanks Steve.
My MAX 7221 is still on order.
I'll get back to the forum with my findings.

achuri
- 12th October 2005, 14:51
here is some code wrote for this purpose. Works well.


decode VAR byte
decode = %00001001
intens VAR byte
intens = %00001010
limit VAR byte
limit = %00001011
shutdn VAR byte
shutdn = %00001100
test VAR byte
test = $0F

intense (set to max)
LOW PORTD.3
SHIFTOUT PORTD.2, PORTC.4, 1, [intens\8, %00000111\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [intens\8, %00001111\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [intens\8, %00001111\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [intens\8, %00001111\8]
HIGH PORTD.3
'limit (set to scan only 4 of 8 rows) better change this if you want more
LOW PORTD.3
SHIFTOUT PORTD.2, PORTC.4, 1, [limit\8, %00000011\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [limit\8, %00000011\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [limit\8, %00000011\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [limit\8, %00000011\8]
HIGH PORTD.3
'shutdown (shutdown is not in effect)
LOW PORTD.3
SHIFTOUT PORTD.2, PORTC.4, 1, [shutdn\8, %00000001\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [shutdn\8, %00000001\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [shutdn\8, %00000001\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [shutdn\8, %00000001\8]
HIGH PORTD.3
'test (testing. all LEDs on.)
LOW PORTD.3
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000001\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000001\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000001\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000001\8]
HIGH PORTD.3
pause 1000
'test (not testing)
LOW PORTD.3
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000000\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000000\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000000\8]
SHIFTOUT PORTD.2, PORTC.4, 1, [test\8, %00000000\8]
HIGH PORTD.3

row0Var = %01111110
row1Var = %10000001
row2Var = %10100101
row3Var = %10000001
row4Var = %10100101
row5Var = %10011001
row6Var = %10000001
row7Var = %01111110


for i = 0 to 7
LOOKUP i, [%00000001 , %00000010 , %00000011 , %00000100, %00000101, %00000111, %00001000, %00001001 ], rownum

LOOKUP2 i, [row0Var, row1Var, row2Var, row3Var, row4Var, row5Var, row6Var, row7Var], rowbits

low porta.0
low porta.1
SHIFTOUT porta.2, porta.0, 1, [rownum\8, rowbits\8]
high porta.1
next




_________________________
_ariel

JDM160
- 28th October 2005, 21:21
I am trying to use the code achuri posted to better understand how to interface the MaX 7219 with my PIC (18F2331).

I am having a hard time compiling it because of errors, namely with the rowxVar statements. Obviously what was posted is not complete code, but I need help putting it to use for me.

Ultimately what I'm trying to do is display a 3 digit number on a 3 digit LED display using the 18F2331. How exactly do I update or write the number to each digit? Any help would be greatly appreciated...

plasmajocky
- 19th March 2007, 03:14
The following is code that I wrote for the MAX 7219. This is only the sub that I call to initialize and test the display. This was written for a 16F877 but can be ported to just about anything. I am far from a programmer so if anyone out there can clean this up or make it better please let me know. I know this code works, as we have shipped many units running it. You must, of course, setup your ports and outputs. Hope this helps - if anyone finds this usefull I would love to hear from you! Feel free to cut and paste this but please pass on help to others - we all must stick together!

LEData VAR PORTC.1
CLK VAR PORTC.5
Load VAR PORTC.0




Max_init:

ShiftOut LEData,clk,MSBFIRST,[%0000100111111111\16] ' Reg. 9 Decode
PulsOut Load,10


ShiftOut LEData,clk,MSBFIRST,[%0000101000001111\16] ' Reg. A Intensity
PulsOut Load,10


ShiftOut LEData,clk,MSBFIRST,[%0000101100000111\16] ' Reg. B Scan Limit
PulsOut Load,10



ShiftOut LEData,clk,MSBFIRST,[%0000110000000001\16] ' Reg. C Shutdown
PulsOut Load,10



ShiftOut LEData,clk,MSBFIRST,[%000011110000000\16] ' Reg. F Display Test
PulsOut Load,10



' Blank the display
digit = 8
For x = 1 TO 8

ShiftOut LEData,clk,MSBFIRST,[digit,$F]
PulsOut Load,10
digit = digit - 1

Next

' Test the display by writting 8's to each digit and scrolling them across

digit = 8
For x = 1 TO 8

ShiftOut LEData,clk,MSBFIRST,[digit,8]
PulsOut Load,10
Pause 500
ShiftOut LEData,clk,MSBFIRST,[digit,$F]
PulsOut Load,10
digit = digit - 1


Next





' Write H
digit = 1
ShiftOut LEData,clk,MSBFIRST,[digit,$C]
PulsOut Load,10


' Write E
digit = 2
ShiftOut LEData,clk,MSBFIRST,[digit,$B]
PulsOut Load,10

' Write L
digit = 3
ShiftOut LEData,clk,MSBFIRST,[digit,$D]
PulsOut Load,10
digit = 4

' Write L
digit = 4
ShiftOut LEData,clk,MSBFIRST,[digit,$D]
PulsOut Load,10
digit = 4

' Write 0
digit = 5
ShiftOut LEData,clk,MSBFIRST,[digit,0]
PulsOut Load,10
digit = 4

Pause 250

' Blink it 5 times

For x = 1 TO 4

ShiftOut LEData,clk,MSBFIRST,[%0000110000000000\16] ' Reg. C Shutdown ON
PulsOut Load,10

Pause 150


ShiftOut LEData,clk,MSBFIRST,[%0000110000000001\16] ' Reg. C Shutdown OFF
PulsOut Load,10

Pause 200

Next

Pause 1000

Return

l2_star
- 6th February 2010, 21:44
Unfortunaly none of these projects does not work.
The program of using the PROTEUS to check.
I want to do a project with a running line is from PIC 16f877 and driver MAX 7221.

We also managed if someone let the finished project + program

I apologize for my English, I am from Ukraine and use a translator Google.

l2_star
- 6th February 2010, 21:47
leo_star.86@mail.ru

plasmajocky
- 7th February 2010, 06:17
What about the code does not work? We have shipped many units running this code??
Have you actually compiled and ran it?

l2_star
- 7th February 2010, 15:43
У МЕНЯ НЕ работает код. что-то не так

l2_star
- 7th February 2010, 15:43
sorry.

I did not have working code. something wrong

plasmajocky
- 8th February 2010, 17:12
Did you get the code working?

l2_star
- 8th February 2010, 22:30
code received thanks.
But I can only check on Tuesday, as How many will check immediately write.

hope to earn.

plasmajocky
- 9th February 2010, 01:04
I am not sure I understand but you have my email address if you need to contact me. Let me know if you require help.

Joe S.
- 9th February 2010, 07:11
I guess I am having a hard time figuring why anyone would use this dedicated $12.95 per each chip, when for the same money you can buy a nice spi display or for less use a cheap PIC to do this chips job, that's why I ordered a "sample" so I can learn what you all seem to know.
http://cgi.ebay.com/1-5-Character-Height-7-segment-LED-Information-Board_W0QQitemZ110489265227QQcmdZViewItemQQptZLH_D efaultDomain_0?hash=item19b9ac644b