Driving the MAX6957

Posted on February 21, 2015

Writing to the SPI Interface

The SPI interface is working on the Raspberry Pi and so I’m getting ready to send some information to the 4-Wire-Intefaced 20-Port LED Display Driver and I/O Expander (MAX6957), called the 6957 from now on. The issue that is mentioned from the data sheet is that the 6957 uses 16 bit words but the driver only uses eight bit words. You can change the word size but then you get an error when you try to send something. I guess those parameters are primarily decorative.

In order to test if the Raspberry Pi’s SPI interface would work for the 6957 I wrote some test code (which I’ll put up later) to send out the number 0xFFAA. I wanted to see what was actually coming out on the bus so I looked at it with the wonderful logic analyzer by Saleae. A screenshot is shown below.

Logic analyzer shows 16 bit write as two 8 bit writes.

You can see that we get two discrete writes of the data. But! The good news is that the chip select is held down the entire time. Other than some weird clock skew between bytes we can write a 16-bit word! Eagle eyes will notice though that the MSB for each work comes out properly but the bytes themselves are reversed from the perspective of a big endian write. A byte flip later and I send out the data byte 0xF5A5 and it appears in the proper order. The logic analyzer output is shown below.

Logic analyzer shows 16 bit write as two 8 bit big-endian writes.

It works perfect. Now to write some code to talk to the 6957.

Flashing an LED

I want to write a simple program to flash an LED driven by the 6957 connected to a single LED. The circuit that I come up with is shown below.

SPI to LED test circuit.

The labels shown on the connection are the same as the signal names given by the Adafruit T-Cobbler Plus. Since the 6957 controls all of the current limiting you don’t need a resistor. The sequence of codes to light port 22 (P22) is the following

0x0D00 ; Configures P22 (and others) as an LED driver. 0x36FF ; Turns on P22 0x020A ; Set the global current control to about 16mA 0x0401 ; Take 6957 out of shutdown mode

I wrote an SPI driver based upon the test program I used earlier and then I used that to write a short test program that flashes an LED every second. After some playing around it works! Admittedly it’s a very expensive LED flasher!

Flashing an LED.

What’s Next?

Now that I’ve got an LED working it’s time to use the 6957 for what it is designed to do; drive a multi-segmented LED display!