Tutorial in using 28x1 to drive a MAX7219 for 8x8 led matrix

Basrad

Member
Hi all,

I know there are some recommendations for other post regarding these chips, but I cant seem to find anything that helps, or at least that I understand.

The clock examples etc that ive found are mainly for using the chips to drive 7 seg 8.-displays. I want to drive a 8x8 matrix.

I've read something about fake chips.. I hope mine arnt fake. I have 4 and they all seem to do the same thing..

The MAX7219 data sheet says "on initial power-up, all registers are reset / blank screen is shown" - This does not seem to be the case. All chips seem to startup showing some L.E.D on... humm?

Anyway, connected to a 28x1 to see if I could issue commands using the HSPIOUT command. After using the HSPISETUP.


HSPISETUP is a little confusing for me..

my chip -

on rising edge of CLK = 16bit shift into register

this should be regardless of LOAD?

CS should be low to clock data in or out

cs raising edge latches data

cs must go high during or after 16th clock pulse to latch the data.

So this information should result in my HSPISETUP configuration?


I used iny miny mo to guess I could use:

setfreq m8
hspisetup spimode00, spifast ; ??????????????????????? I chose spifast as set the internal clock to 8mhz?

I then connected up my module to a 28x1 as per the diagram.


Then I tried to send the test display command to the screen, and, behold.. Some life.. The screen switches between 2 states.. I was expecting full screen on (all leds on) and then all leds off... But instead I get, one frame with few leds on, and the 2nd frame with some other leds on :(

bit confused regarding the correct layout for the command addressing and issuing.

data sheet says the serial data is 16bits... D15 to D0

When I write HSPIOUT (0X00,0X09) for example.. which side is the D15 side and which side is the D0 end?

to me HSPIOUT (0X00,0X09) is saying Decode mode = 0? or is is vicer versa?

is writing HSPIOUT (0x0,0x9) the same as above?

Any advice really appreciated.. And if anyone has a working example code I could learn a whole lot from it! :D

Hope everyone has a lovely weekend, and doesnt waste too much time for my posts!! :D
 

Attachments

Billo

Senior Member
The 7219 does not care whether the LOAD signal is high or low. It will clock data in regardless. It will load that data on a rising edge of the LOAD line, and that rising edge must be on or after the rising edge 16th clock pulse. It just should not be before.

So you need to do it like this:

1) Keep the LOAD signal low normally.
2) Clock your 16 bits of data to the 7219.
3) Once you have completely finished clocking your data to the 7219, send a short positive pulse on LOAD.

That's it. The actual time between the rising edge of the 16th clock signal and the issuing of the pulse on LOAD is not critical as long as you issue that LOAD pulse before you attempt to clock in the next 16 bits of data.

Remember, it expects the MSB first (b15) and the LSB (b0) last.

You only talk about the ~CS signal if you are talking about a 7221. For the 7219 it is a LOAD signal and works differently.
 

PaulRB

Senior Member
Hi Basrad,

I seem to remember that for the Max7219, its the most significant bit you send first and the least significant last, so the same with bytes. You should send the register number (8 bits, of which only 5 used) followed by the data (8 bits).

Here's the code I wrote, but I am "bit-banging" wirth an 08m2: http://www.picaxeforum.co.uk/showthread.php?22115-4x4x4-LED-Cube-using-08M2-and-MAX7219&highlight=max7219

Here's a thread about spotting fake max7219: http://www.picaxeforum.co.uk/showthread.php?22481-Real-or-fake&highlight=real+fake

Mine are fake but seem to work OK.

Paul
 

Basrad

Member
Billo - thanks, I did see the 7219 not caring about load state, but thought I would set it up just encase it was an issue. I think I've tried the method you list, but does not work for me :(

Think I'm calling LOAD and CS the same thing.. its marked LOAD on the module, but I'm treating it as CS


Paul - thanks, looked at your example, unfortunately its a little complex for me at this stage, I was hoping to test the units by simply switching all LED on then Off using the Test screen command and clear screen... It just doesnt work.

Think ill email the ebay seller, as mine certainly match the fake looking ones :( No dimple at pin 1

I was thinking the following code should do something..

All the HSPIOUT commands, Ive tried sending vicer versa as im not sure on which goes first

e.g HSPIOUT (0x9,0x0) vs HSPIOUT (0x0,0x9)


Code:
init:

hspisetup spimode00, spifast ; spi mode 1,1
symbol CS = b.7
pause 200


Low cs
HSPIOUT (0X00,0X09) 	; set to no decode mode	
high cs
pause 5

Low cs
HSPIOUT (0x1,0xC) 	; set to normal operation mode	
high cs
pause 5



main:

low cs
HSHOUT (0x1,0xF) 		; set display test mode on
high cs
pause 5


pause 250

low cs
hspiout (0x0,0xF) 		; set display to normal mode, test off?
high cs
pause 5



pause 250
goto main
 
Last edited:

PaulRB

Senior Member
Basrad, I don't see the comnand to set the number of digits to scan in your code. Take another look at my code, just the first few lines after "main:".
 
Top