I am new in the world of embedded software. But I was having normal challenge in blinking LED and SPI bridge communication on STM32F0-Discovery. All this work fine. Now I was planing to go to next level, but for sure I do not really understand some things. To program I am using STM32Cube for configuration ( 8 Bit datasize, 187,5KBits/s and MSB first) as usual.

For testing I define:

uint8_t display[8] = {0,0x7F,0xFF,0xCC,0xCC,0xCC,0xFF,0xF}; //A

For sending the data, as through the STM32Cube all the initialization is done, I wrote the following code in the while-loop:

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_4, GPIO_PIN_RESET); //here is chip select
trasnmit = HAL_SPI_Transmit_IT(&hspi1, display, 8);
receive = HAL_SPI_Receive_IT(&hspi1, Rxbuff, 8);

Of course I am getting my CLK on the oscilloscope but no data at the DIN-Pin of the MAX7219 (see: https://www.ebay.de/i/273605021101?chn=ps)

While debugging, I can see that the transmit function is being skipped, what could be the cause? But the return value is always on HAL_OK.

Could somebody help me with a step by step config of the MAX7219 based on STM32, so that I can better understand where my problem is.

  • \$\begingroup\$ I edited the question to make it more readable. If you feel like I changed to much, please rollback to the original. \$\endgroup\$ – Arsenal Apr 30 at 15:02

First, try to send data in polling mode (without IRQ) with: HAL_SPI_Transmit

  • \$\begingroup\$ Indeed it is not answer to the question asked, but this might be the answer needed. I would have suggested this too if the question was about how to fix it instead of what is wrong with it. \$\endgroup\$ – Justme Apr 30 at 11:23

The code wants to write over SPI using interrupts, does not wait for transmission completion and immediately wants to receive over SPI using interrupts again. That should answer why it does not work.

  • \$\begingroup\$ removing the receive command, does not change the solution. and i am asking myself what shall i change to get it work. could you propose a guide solution? \$\endgroup\$ – Rompel Apr 30 at 9:10
  • \$\begingroup\$ It does not fix it, because, code sets CS low, starts transmitting data in background using interrupts, does not wait for transmit completion and immediately sets CS high, so chip does not see any bytes while CS low. Solution may be not to use interrupts, or to read the manual or comments in library code how to use interupt driven SPI properly. \$\endgroup\$ – Justme Apr 30 at 9:22

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.