Hello!

I have cascaded together (6x) Max7219 display drivers. I have no problems driving them with my 16F628A, but the code I am using is a little space hungry. It is simple, it works, but I am sure there are other alternatives, but I am not seeing it.

I was wondering, can anyone assist me with making my subroutine codes a little shorter for the MAX7219 without altering the timing for SHIFT_OUT and LOAD High sequence?

To send data to other Max7219, you have to insert No-Op after the intended data. If you want to send to the third Max7219, you send out the 16bits and then follow with 2 No-Op 16bits, which are just all ‘0’

Have a look at my subroutines. I have set up a Transfer Label for each chip, with the required No-Ops in place…but the problem is it is space hungry on the 16F628A.
Code:
Transfer:
  	ShiftOut Dta,Clk,msbfirst,[Register,R_Val] 	' Shift Out the Register first, then the data
	High Load 					' Data is now latched in and displayed
@ Nop
	Low Load					' Disable the MAX7219 
	Return						' Exit from Subroutine
	
Transfer1:
  	ShiftOut Dta,Clk,msbfirst,[Register,R_Val]	' Shift Out the Register first, then the data
   	ShiftOut Dta,Clk,msbfirst,[0,0]			' Send No-Op Command
   	High Load 					' Data is now latched in and displayed
@ Nop
	Low Load					' Disable the MAX7219 
	Return						' Exit from Subroutine
	
Transfer2:
  	ShiftOut Dta,Clk,msbfirst,[Register,R_Val] 	' Shift Out the Register first, then the data
   	ShiftOut Dta,Clk,msbfirst,[0,0]			' Send 2 sets of No-Op Commands
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	High Load 					' Data is now latched in and displayed
@ Nop
	Low Load					' Disable the MAX7219 
	Return						' Exit from Subroutine
	
Transfer3:
  	ShiftOut Dta,Clk,msbfirst,[Register,R_Val] ' Shift Out the Register first, then the data
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	High Load					' Data is now latched in and displayed
@ Nop
	Low Load					' Disable the MAX7219 
	Return						' Exit from Subroutine
	
Transfer4:
  	ShiftOut Dta,Clk,msbfirst,[Register,R_Val] ' Shift Out the Register first, then the data
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	High Load 					' Data is now latched in and displayed
@ Nop
	Low Load					' Disable the MAX7219 
	Return						' Exit from Subroutine
	
Transfer5:
  	ShiftOut Dta,Clk,msbfirst,[Register,R_Val] ' Shift Out the Register first, then the data
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	ShiftOut Dta,Clk,msbfirst,[0,0]
   	High Load 					' Data is now latched in and displayed
@ Nop
	Low Load					' Disable the MAX7219 
	Return						' Exit from Subroutine
Thinking I can make it shorter, I used the FOR…NEXT commands in combination with the IF…THEN,……it compiled well, wrote it on the chip……..BUT This method totally stuffed up the correct timing of pulling up the load.
So while the 16F628A was working with the FOR…NEXTcommands…the LOAD timing sequence had already lapsed and data was lost. I was thinking of further adding another 2 Max7219 for a total of eight, but I won't have any code space left for other functions...:-(

Apart from putting on the code for the 16F648 (More space) is there any other possibilities or ideas to make this subroutine a little more compact?

Many thanks