LED Maestro
Senior Member
Hey, so I am reluctantly asking yet another question after trawling the forum, and the rest of the internet, for any hints on what I'm about to ask, for what seems like an eternity.
I can't, for the life of me, get my MAX7221 to display, sequentially, the numbers 0-9. I am running it off of a 28X1 with the appropriate connections in place as per the code below which I came across whilst on here.
This is my first venture into SPI comms and I've read, re-read and re-re-read the datasheet for the MAX7221/7219 many many times and I'm still confused I must admit.
The code was written for the 7219 but as that and the 7211 are virtually identical, I assumed it would work as is but apparently not.
As always, any help is appreciated.
Thanks
I can't, for the life of me, get my MAX7221 to display, sequentially, the numbers 0-9. I am running it off of a 28X1 with the appropriate connections in place as per the code below which I came across whilst on here.
This is my first venture into SPI comms and I've read, re-read and re-re-read the datasheet for the MAX7221/7219 many many times and I'm still confused I must admit.
The code was written for the 7219 but as that and the 7211 are virtually identical, I assumed it would work as is but apparently not.
As always, any help is appreciated.
Thanks
Code:
#Picaxe28x1
symbol dout = b.1
symbol cs = b.2
symbol cl = b.3
symbol outreg = b1
symbol outval = b0
symbol outword = w0
symbol bitcounter = b2
symbol tths = b3
symbol thos = b4
symbol hnds = b5
symbol tens = b6
symbol ones = b7
symbol counter = b8
symbol n0 = %01111110
symbol n1 = %00110000
symbol n2 = %01101101
symbol n3 = %01111001
symbol n4 = %00110011
symbol n5 = %01011011
symbol n6 = %01011111
symbol n7 = %01110000
symbol n8 = %01111111
symbol n9 = %01111011
symbol decode = 9
symbol brite = 10
symbol scan = 11
symbol display = 12
pause 500
outreg = decode
outval = 0
gosub shifter
pause 500
outreg = brite
outval = 10
gosub shifter
pause 500
outreg = scan
outval = 0
gosub shifter
pause 500
outreg = display
outval = 1
gosub shifter
pause 500
main:
for counter = 0 to 9
lookup counter, (n0,n1,n2,n3,n4,n5,n6,n7,n8,n9), outval
outreg = 1
gosub shifter
pause 100
next counter
goto main
shifter:
low cs
for bitcounter = 0 to 15
if bit15 = 1 then
high dout
else
low dout
endif
high cl
low cl
outword = outword * 2
next bitcounter
high cs
low cs
return