Shifting to shift registers
Hi
i'm using the Max7219, well actaully 6 of them. But for the life of me, I can't work out how to shift more than 8x8 bits to them at once. How would i shift out a larger graphic to them?
i'm using the Max7219, well actaully 6 of them. But for the life of me, I can't work out how to shift more than 8x8 bits to them at once. How would i shift out a larger graphic to them?

Comments
· SHIFTOUT Dpin, Cpin, MSBFIRST, [noparse][[/noparse]data1, data2, data3, data4, data5, data6, data7, data8]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
however, I'm receiving the values via SERIN, and this is where is gets confusing....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
forgive the messy code, just trying to get it to work.
progPin CON 16 ' The programming PIN ledCmd VAR BYTE serStr VAR BYTE(10) d7219 VAR BYTE d7219_b VAR BYTE d7219_c VAR BYTE d7219_d VAR BYTE d7219_e VAR BYTE d7219_f VAR BYTE Clock CON 0 ' shift clock to MAX7219 DPin CON 1 ' shift data to MAX7219 Load CON 2 ' '======Constants========================== Decode CON $09 ' bcd decode 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 '==========Variables========================= index VAR NIB ' loop counter idxOdd VAR index.BIT0 ' is index odd? (1 = yes) ' 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 'inBlips VAR WORD '=====EEPROM Data============================= '=========Initialization====================================== '++++++This is edited code++++ '++++ LOOKUP index,[noparse][[/noparse]Scan,7,Intensity,7,ShutDn,1],d7219 +++++ '=============================================================== LOW Load Initialize: DIRL = %111 ' clock, data and load pins FOR index = 0 TO 5 LOOKUP index,[noparse][[/noparse]Scan,7,Intensity,7,ShutDn,1],d7219 SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]d7219] IF idxOdd = No THEN NoLoad PULSOUT Load,3 ' load parameter NoLoad: NEXT 'DATA Main: get_Data: ' SEROUT progPin, 84, ' SEND the serial DATA FOR col = 1 TO 8 SERIN progPin, 84, [noparse][[/noparse]WAIT ("*"), BIN d7219] ' wait for Comm SEROUT progPin, 84, ' SEND confirmation SERIN progPin, 84, [noparse][[/noparse]WAIT ("*"), BIN d7219_b] ' wait for Comm SEROUT progPin, 84, ' SEND confirmation SERIN progPin, 84, [noparse][[/noparse]WAIT ("*"), BIN d7219_c] ' wait for Comm SEROUT progPin, 84, ' SEND confirmation SERIN progPin, 84, [noparse][[/noparse]WAIT ("*"), BIN d7219_d] ' wait for Comm SEROUT progPin, 84, ' SEND confirmation SERIN progPin, 84, [noparse][[/noparse]WAIT ("*"), BIN d7219_e] ' wait for Comm SEROUT progPin, 84, ' SEND confirmation SERIN progPin, 84, [noparse][[/noparse]WAIT ("*"), BIN d7219_f] ' wait for Comm SEROUT progPin, 84, ' SEND confirmation SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_f] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_e] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_d] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_c] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_b] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219] PULSOUT Load,3 NEXT PAUSE 100 GOTO MainClock CON 0 ' shift clock to MAX7219 DPin CON 1 ' shift data to MAX7219 Load CON 2 ' '======Constants========================== Decode CON $09 ' bcd decode 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 '==========Variables========================= index VAR NIB ' loop counter idxOdd VAR index.BIT0 ' is index odd? (1 = yes) d7219 VAR BYTE d7219_b VAR BYTE d7219_c VAR BYTE d7219_d VAR BYTE d7219_e VAR BYTE d7219_f 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 eeAddr3 VAR BYTE eeAddr4 VAR BYTE eeAddr5 VAR BYTE eeAddr6 VAR BYTE vScroll VAR WORD ' scrolling data buffer '=====EEPROM Data============================= ' column between characters Char_0 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00111110 DATA %00100010 DATA %00000100 DATA %00011100 DATA 0 Char_1 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00111000 DATA %01000100 DATA %01000100 DATA %10101010 DATA 0 Char_2 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00111000 DATA %01000100 DATA %01000100 DATA %10101010 Char_3 DATA %00010000 DATA %00100010 DATA %00111110 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 Char_4 DATA %01000100 DATA %01000100 DATA %00111000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 Char_5 DATA %01000100 DATA %01000100 DATA %00111000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 DATA %00000000 DATA 0 '=========Initialization====================================== Initialize: DIRL = %111 ' clock, data and load pins FOR index = 0 TO 5 LOOKUP index,[noparse][[/noparse]Scan,7,Intensity,7,ShutDn,1],d7219 SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]d7219] IF idxOdd = No THEN NoLoad PULSOUT Load,3 ' load parameter NoLoad: NEXT Main: FOR char = 0 TO 4 LOOKUP 0,[noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5],eeAddr1 LOOKUP 1,[noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5],eeAddr2 LOOKUP 2, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5],eeAddr3 LOOKUP 3, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5],eeAddr4 LOOKUP 4, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5],eeAddr5 LOOKUP 5, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5],eeAddr6 GOSUB ShowChar PAUSE 1000 NEXT END '================================================================================= ShowChar: FOR col = 1 TO 8 READ (eeAddr1 + col - 1),d7219 READ (eeAddr2 + col - 1),d7219_b READ (eeAddr3 + col - 1),d7219_c READ (eeAddr4 + col - 1),d7219_d READ (eeAddr5 + col - 1),d7219_e READ (eeAddr6 + col - 1),d7219_f SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_f] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_e] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_d] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_c] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219_b] SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219] PULSOUT Load,3 NEXT RETURNQ: Do you have control over the transmitting end?· If yes, just use one sync character and send a single byte (the value) for each position instead of the eight-byte binary string (this will speed up comms significantly).· Then you can do this:
· SERIN ProgPin, Baud, [noparse][[/noparse]WAIT ("*"), STR d7219\6]
(Note: You should NOT hardcode baud values -- put them into a constant.· Trust me on this.)· If you're sending the data as binary strings to avoid a conflict with the sync character, change to HEX2 format and do it like this:
· SERIN ProgPin, Baud, [noparse][[/noparse]WAIT ("*"), HEX2 d7219(0), HEX2 d7219(1), HEX2 d7219(2),··· ' <
························HEX2 d7219(3), HEX2 d7219(4), HEX2 d7219(5)]
That eliminates six bytes per item.· I've also put the 7219 data into an array to simplify other processes.
In your second program, this section of code:
· FOR char = 0 TO 4
·· ·LOOKUP 0, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5], eeAddr1
·· ·LOOKUP 1, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5], eeAddr2
·· ·LOOKUP 2, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5], eeAddr3
·· ·LOOKUP 3, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5], eeAddr4
·· ·LOOKUP 4, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5], eeAddr5
·· ·LOOKUP 5, [noparse][[/noparse]Char_0,Char_1,Char_2,Char_3,Char_4,Char_5], eeAddr6
·· ·GOSUB ShowChar
··· PAUSE 1000
· NEXT
... is a big waste of space since you're always using a fixed index for LOOKUP.· Is that what you meant to do?· And if your EE defintiions are of a fixed size and place in order, you can simply calculate an offset address.· This line of code will take the value in "theChar" and calculate the address for it:
· eeAddr = Char_0 + (theChar * 9)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
yes, i do have control over the transmitting end. perhaps it would've been helpful to explain what i'm doing. i am using Processing, ie. semi-Java, taking an image, converting it to binary to represent the black and white (on and off) states. That's why I'm using binary on both sides. So I'm only ever sending 1's and 0's. I will probably convert these to decimal later on, but at moment just trying to get it working.
so i've modified the code slightly, but it's still not working. Should i be sending all 64 bits of one 8x8 matrix, or should it be done as it is now, row for row?
progPin CON 16 ' The programming PIN ledCmd VAR BYTE serStr VAR BYTE(10) d7219 VAR BYTE d7219_b VAR BYTE d7219_c VAR BYTE d7219_d VAR BYTE d7219_e VAR BYTE d7219_f VAR BYTE Baud CON 84 Clock CON 0 ' shift clock to MAX7219 DPin CON 1 ' shift data to MAX7219 Load CON 2 ' '======Constants========================== Decode CON $09 ' bcd decode 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 '==========Variables========================= index VAR NIB ' loop counter idxOdd VAR index.BIT0 ' is index odd? (1 = yes) ' 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 '=========Initialization====================================== LOW Load Initialize: DIRL = %111 ' clock, data and load pins FOR index = 0 TO 5 LOOKUP index,[noparse][[/noparse]Scan,7,Intensity,7,ShutDn,1],d7219 SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]d7219] IF idxOdd = No THEN NoLoad PULSOUT Load,3 ' load parameter NoLoad: NEXT 'DATA Main: get_Data: FOR col = 1 TO 8 SERIN ProgPin, Baud, [noparse][[/noparse]WAIT ("*"), BIN d7219(0), BIN d7219(1), BIN d7219(2), BIN d7219(3), BIN d7219(4), BIN d7219(5)] SEROUT progPin, Baud, ' SEND confirmation FOR row = 0 TO 5 SHIFTOUT Dpin,Clock,MSBFIRST,[noparse][[/noparse]col,d7219(row)] NEXT PULSOUT Load,3 NEXT PAUSE 100 GOTO MainPost Edited (george miyagi) : 7/3/2005 6:54:30 PM GMT