cancel
Showing results for 
Search instead for 
Did you mean: 

MOSI data during HAL_SPI_Receive operation

S.Kamath
Associate II

I'm using Nucleo-F767 with IAR IDE. I have created project using STM32CubeMx v6.3.0.

I want to send one byte over MOSI and receive 27 bytes of data from SPI slave device on MISO. I noticed that random data is seen on MOSI line from 2nd byte. How to make MOSI data as 0x00 for 27 bytes i.e., during SPI Read operation.

Scope capture attached.

Code:

 HAL_SPI_Transmit(&hspi3, spiTxBuf, 1, 50);

 HAL_SPI_Receive(&hspi3, spiRxBuf3, 27, 50);

Note: MOSI data is required to make 0x00 in order to make slave device functionality working fine as expected.

0693W00000D1cf2QAB.png

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> How to make MOSI data as 0x00 for 27 bytes i.e., during SPI Read operation.

Use HAL_SPI_TransmitReceive and set the outgoing buffer bytes to 0x00.

Move both calls into a single call to HAL_SPI_TransmitReceive with length 28 and discard the data you don't want.

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

View solution in original post

2 REPLIES 2
TDK
Guru

> How to make MOSI data as 0x00 for 27 bytes i.e., during SPI Read operation.

Use HAL_SPI_TransmitReceive and set the outgoing buffer bytes to 0x00.

Move both calls into a single call to HAL_SPI_TransmitReceive with length 28 and discard the data you don't want.

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

Thanks, Issue got resolved ..!