7219 shifting
george miyagi
Posts: 48
hi
got the 7219 working!!! but am having a funny problem where the data is shifting (sometimes) one column to the right.
Is there a bit of buggy code, or could it be a power problem.
Here's the code, adapted from the Nuts n Volts article:
also, what is the theory around cascading/daisy chaining the 7219s. how do you get date onto say a second 7219
thanks
george
got the 7219 working!!! but am having a funny problem where the data is shifting (sometimes) one column to the right.
Is there a bit of buggy code, or could it be a power problem.
Here's the code, adapted from the Nuts n Volts article:
' ----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- Clock CON 0 ' shift clock to MAX7219 DPin CON 1 ' shift data to MAX7219 Load CON 2 ' ' ----[noparse][[/noparse] Constants ]------------------------------------------------------- ' Decode CON $09 ' bcd decode 'Decode CON $00 Intensity CON $0A ' brightness Scan CON $0B ' scan (column) limit ShutDn CON $0C ' shutdown (1 = on) Test CON $0F ' display test mode Yes CON 1 No CON 0 ' ----[noparse][[/noparse] Variables ]------------------------------------------------------- ' index VAR NIB ' loop counter idxOdd VAR index.BIT0 ' is index odd? (1 = yes) d7219 VAR BYTE ' data for MAX7219 char VAR BYTE ' character ee address col VAR NIB ' column value row VAR NIB ' row value eeAddr1 VAR BYTE ' ee pointer eeAddr2 VAR BYTE vScroll VAR WORD ' scrolling data buffer ' ----[noparse][[/noparse] EEPROM Data ]----------------------------------------------------- ' Char_B DATA %11111111 ' xxxxxxx DATA %10111111 ' x..x..x DATA %10111111 ' x..x..x DATA %11111111 ' x..x..x DATA %11111111 ' .xx.xx. DATA %11111111 ' .xx.xx. DATA %11111111 ' .xx.xx. DATA %11111111 ' .xx.xx. DATA 0 Char_S DATA %01010101 ' .x..xx. DATA %10101011 ' x..x..x DATA %01010101 ' x..x..x DATA %10101011 ' x..x..x DATA %01010101 ' .xx..x. DATA %10101011 ' .xx.xx. DATA %01010101 ' .xx.xx. DATA %10101011 ' .xx.xx. ' DATA 0 Char_2 DATA %10101010 ' x..x..x DATA %11010101 ' x..x..x DATA %10101010 ' x..x..x DATA %11010101 ' .xx..x. DATA %10101010 ' .xx.xx. DATA %11010101 ' .xx.xx. DATA %10101010 ' .xx.xx. DATA %11010101 ' .x..xx. Char_3 DATA %00011000 ' x..x..x DATA %00111100 ' x..x..x DATA %01111110 ' x..x..x DATA %11011011 ' .xx..x. DATA %11111111 ' .xx.xx. DATA %01011010 ' .xx.xx. DATA %10000001 ' .xx.xx. DATA %01000010 ' .x..xx. ' ----[noparse][[/noparse] Initialization ]-------------------------------------------------- ' Initialize: DIRL = %111 ' clock, data and load pins FOR index = 0 TO 5 ' six addresses & values (from 0 to 5) LOOKUP index,[noparse][[/noparse]Scan,7,Intensity,7,Shutdn,1],d7219 ' those values stored in VAR d7219 one by one SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]d7219] ' ... and sent to 7219 when pulsed IF idxOdd = No THEN NoLoad ' not a clue what this does PULSOUT Load,3 ' pulsed here (sent to 7219) NoLoad: 'DEBUG ? d7219 NEXT ' ----[noparse][[/noparse] Main Code ]------------------------------------------------------- ' Main: Flash_Characters: ' on screen, one at a time FOR char = 0 TO 3 LOOKUP char,[noparse][[/noparse]Char_B,Char_S,Char_2,Char_3],eeAddr1 GOSUB ShowChar PAUSE 2000 NEXT GOTO Main ' ----[noparse][[/noparse] Subroutines ]----------------------------------------------------- ' ShowChar: FOR col = 1 TO 8 ' character is 8 columns wide READ (eeAddr1 + col - 1),d7219 ' read column data fromEEPROM SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219] PULSOUT Load,3 PAUSE 50 NEXT RETURN
also, what is the theory around cascading/daisy chaining the 7219s. how do you get date onto say a second 7219
thanks
george
Comments
http://pdfserv.maxim-ic.com/en/ds/MAX7219-MAX7221.pdf
I think all you need to do is shiftout the right number of bits and then kick the load9/CS) line. Think of them as serially cascaded shift registers.
I don't see anything overtly wrong with the code, but I don't have time to do more than glance at it right now. Hopefully someone else can give it a more in-depth look.
My $0.02
-dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
This is not a sig. This is a duck. Quack.