1
\$\begingroup\$

So I purchased a cheap Double-7-Segment display piece (specifically this one: https://www.amazon.com/dp/B01D0WSCJA)

To do some tinkering with. I've messed around with it manually to make sure it works and it does. However from reading the datasheet I can't quite tell if the 7219 supports SPI. The datasheet im using is: https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf

It states that the 7221 supports SPI but doesn't mention anything for the 7219. So when dealing with this with a normal MCU...do we just bitbang it specifically trying to match the timing diagram?

If that's true (and this is one I ran into when doing it manually with switches/buttons for testing) I get confused on the last timing portion. Specifically when CS/LOAD goes high and then low the last time. Do we pull CS/LOAD high on the last Data bit CLK latch? or does it have to go high RIGHT as the CLK is falling on the last data bit?

And we just need to make sure the LOAD stays high for a sufficient time before pulling it back down? (The last data bit portion always screwed me up). Im having a hard time telling how to handle that in code (Since I screwed up doing it manually, which I tend to try out to learn the datasheet first). I just can't tell if it matters when LOAD goes high at the very end if that needs to be when CLK has latched the last data bit or it needs to start going high before then. The data is latching on the rising edge correct? (of CLK)

One thing I learned when testing this was that it has to be put in Shutdown Mode-Normal operation before doing anything (Which had me stumped for awhile). Because I thought it would be accepting data when it was first started up. Is there anything else im missing on "startup" mode?

\$\endgroup\$
3
\$\begingroup\$

The datasheet seems pretty clear. The 7221 has an SPI compliant /CS input, whereas the 7219 takes any 16 bits it sees:

For the MAX7219, serial data at DIN, sent in 16-bit packets, is shifted into the internal 16-bit shift register with each rising edge of CLK regardless of the state of LOAD.

For the 7221 it says:

LOAD/CS must go high concurrently with or after the 16th rising clock edge, but before the next rising clock edge

That just means that you must take LOAD/CS high after sending 16 bits and before any 17th bit is sent.

So, you can safely talk to the 7219 via SPI if it is the only device on that bus, i.e. you don't need a /CS signal, or if at least the clock line is dedicated for the 7219.

\$\endgroup\$
  • \$\begingroup\$ So would it be safe to bring LOAD/CS high on the falling edge of the 16th bit? Just as long as it's high before the17th rising edge should be safe? (The timing diagram makes it seem like it has to be the EXACT same time, which would be difficult/impossible to make them happen at the same time right?) \$\endgroup\$ – msmith1114 Jan 29 '19 at 3:20
  • \$\begingroup\$ @msmith1114 Yes, the falling edge, being in the middle between the 16th and 17th rising edge, would be the perfect time to raise LOAD. \$\endgroup\$ – JimmyB Feb 1 '19 at 15:22
1
\$\begingroup\$

I've used Arduino SPI with MAX7219 at default settings: 4 MHz clock, MSBFIRST, Mode0, like so:

digitalWrite (ssPin, LOW);
SPI.transfer(registerAddress);
SPI.transfer(dataToSend);
digitalWrite (ssPin, HIGH);

Works fine.

This example uses four MAX7219s each driving an 8x8 LED display. Each has its own ssPin line (cs/, or Load/). SCK & MOSI are connected in parallel to each. Driven from a Duemilanove.

https://www.youtube.com/watch?v=hwYqgyMc5S4

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.