cancel
Showing results for 
Search instead for 
Did you mean: 

SPI transmit question/issue

70nKA
Associate

Hi,

I have a custom board which has an STM32F446RE with implemented SPI peripheral that should communicate with MAX22530 chip. Currently, I am trying to test the SPI interface but am running into something that looks strange.

The SPI ioc configuration is as follows:

70nKA_0-1745606966822.png

and the code inside the main function is:

70nKA_1-1745607051310.png

As you can see, I am just trying to send 3 bytes over the SPI where each byte should be 0x00. The issue I am having to understand is why is there a logical 1 on MOSI line the MOSI line should be in logical 0 during the transmit:

byte.jpg

 - YELLOW: CLK

 - PURPLE: MOSI

So it seems like it is sending 0x08 instead of 0x00. Considering I am using HAL_SPI_Transmit (I am not using a custom function) could there be a bug in built in code for SPI?

If so, I am using 1.17 SW IDE version.

1 REPLY 1
TDK
Guru

The function wants a pointer to the data. You're converting the pointer to an integer, when is then implicitly re-converted to a pointer so the function is not sending the data you want, but the data at memory address 0. This is bad and you should be receiving warning during compilation which is why those lines are underlined in yellow.

Here is what you want:

uint8_t frame = 0;
HAL_SPI_Transmit(&hspi1, &frame, 1, HAL_MAX_DELAY);

 Or this:

uint8_t frame = 0;
HAL_SPI_Transmit(&hspi1, (uint8_t*)&frame, 1, HAL_MAX_DELAY);

 

If you feel a post has answered your question, please click "Accept as Solution".