Using MAX 7221 LED driver
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.
Using 7221 in nodecode mode
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