2
\$\begingroup\$

I Have started making my 1st PCB, as per my other question (Located Here) and have been looking at the datasheet for the MAX7219CNG and studying the library to run it on an Arduino (Located Here)

Now my question is from what I can see in the library, there is a method called spiTransfer that sends the data to the IC to turn on and off the various LEDs. This is done by shifting data containing opcode and data bits. The opcodes are at the top of the .cpp file. For example #define OP_SHUTDOWN 12

I can't find where the related information is in the datasheet to say that 12 = Shutdown.

Am i reading the datasheet wrong or understanding the library wrong. I want to learn how to read a datasheet and implement code to run an IC with out relying on code written by others.

And guidance would be great thanks

asked Jan 1, 2011 at 12:35
\$\endgroup\$

1 Answer 1

6
\$\begingroup\$

That's because it's in the datasheet in hex. :-) Page 7, table 2. I'd have written the define as #define OP_SHUTDOWN 0x0C to be consistent with the datasheet...

answered Jan 1, 2011 at 13:53
\$\endgroup\$
4
  • \$\begingroup\$ Thanks, that helps a lot. I take it that most SPI communications are the same, in you shift op codes then the data length of each depends on the data sheet? \$\endgroup\$ Commented Jan 1, 2011 at 23:48
  • \$\begingroup\$ I think it's more likely that they are all the same size (a byte in this case). The library is just badly written. Control commands (they're not really opcodes) should generally be written in hex, or whatever format the datasheet uses. Mixing bases is a recipe for disaster/unmaintainability. \$\endgroup\$ Commented Jan 2, 2011 at 5:05
  • 1
    \$\begingroup\$ Well my plan is to rewrite the library if for nothing else than the learning value. I will make sure that I use hex values instead of decimal values to keep with the datasheet \$\endgroup\$ Commented Jan 2, 2011 at 9:46
  • 1
    \$\begingroup\$ When you do rewrite it - please post it somewhere! \$\endgroup\$ Commented Jan 3, 2011 at 0:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.