cancel
Showing results for 
Search instead for 
Did you mean: 

Issues involving using a MAX7219 4 x 64 LED Matrix board with SPI

A13XBGA
Associate

Hi all,

 

I have been working on a project that involves using a MAX7219-based 4 x 64 LED matrix display and I experienced various issues regarding how properly control what is being displayed on the board. I used 3 different libraries as a foundation to drive the LED matrix, but no avail. The main issue is that no matter what data I transmit through SPI, the displays seemingly show garbage without any sort of consistency, that is sometimes the LEDs are lighting fast with no coherent pattern and on all 4 displays, other times they are lighting up and then going blank, or simply staying on fully despite not sending the SPI data to light them up Here is a breakdown of what was attempted:

I understand from the datasheet of the MAX7219 IC: the data that is to be transmitted is 16-bit sequence whose first 8 bits contains the address of the row (or some special addresses that can address the entire display for instance) followed by 8 additional bits for the data (that will light up specific LEDs on a row). The question I have regarding that is how does the addressing work when trying to use more than one display (in this case 4), as well as what is the appropriate configuration for the CS pin of the display? Some of the tutorials I have tried to follow never addressed that and I am suspecting that this CS pin might be the reason for some of the issues I have been experiencing. From my understanding, it has to be set to be active low before transmitting the data through SPI, and then it has to be set high after the transmission is completed for a brief time, and then pulled down again. I also used an oscilloscope to check for the signals of the clock (the IC supports up to a frequency of 10MHz and I made sure to be below that value), I also confirm that the proper encoding is being transmitted using SPI (I can see both the bits for the address and the bits for the data) and I see the proper pulse from the CS pin.

uint8_t encoding16[2];

while (1) {

encoding16[0] = 0x0F; //first argument is the register to access

encoding16[1] = 0x0F; //Light up the displays

HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);

HAL_SPI_Transmit(&hspi1,encoding16, 2, 500);

HAL_Delay(10);

HAL_GPIO_WritePin(CS_GPIO_Port,CS_Pin, GPIO_PIN_SET);

HAL_Delay(10);

}

 

In the above snippet, I am attempting to light up all the displays at once, however I am uncertain how to transmit the data to multiple displays. Currently this code only displays garbage on all of the 4 displays using an inconsistent pattern.

Any assistance would be appreciated, I can try and provide more details about what I attempted if need be.

1 REPLY 1

It would help to read the data sheet.

>> I used 3 different libraries as a foundation to drive the LED matrix

Yes, stop doing that and see step one, so you understand how it works and the expectations.

Looks like it expects you to shift a pattern over the wire MOSI/CLK, and *then* latch that content into the device by the LOAD pin transitioning low to high

If you have multiple devices you're expected to daisy-chain MOSI -> DIN, DOUT -> DIN, DOUT -> DIN, .. and share a common CLK and LOAD pin.

For 8 chained displays you'd shift out an array of 32 Bytes, the first bytes getting to the display furthest down the chain.

https://www.analog.com/media/en/technical-documentation/data-sheets/MAX7219-MAX7221.pdf

Only the MAX7221 has a CS (CHIP SELECT) pin option

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..