cancel
Showing results for 
Search instead for 
Did you mean: 

SPI issue

Naresh_
Associate III

Hi ,

i am using STM32H753z, implementing the SPI.

when i using HAL_SPI_TransmitReceive() data is transfer and receive happening but data is mismatching.

when i using HAL_SPI_Transmit(),   HAL_SPI_Transmit_IT()   is showing busy when i debug same wave to HAL_SPI_Receive(),  HAL_SPI_Receive_IT(). 

 

Thank you,

Naresh

HAL_SPI_Receive_IT.pngHAL_SPI_TransmitReceive.pngif (hspi->State != HAL_SPI_STATE_READY)

{

return HAL_BUSY;

}

4 REPLIES 4

Please see the Posting Tips for how to properly post source code, and other details required - including your hardware setup:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

 


@Naresh_ wrote:

transfer and receive happening but data is mismatching.


What, exactly, do you mean by that?

Have you used an oscilloscope or logic analyser to see what's happening on the wires?

Hi Andrew, 

thank you for quick response.  

 i am not use any oscilloscope or logic analyzer.

i doing SPI loopback now i facing issue in receive buffer,

uint8_t Tx_buffer[]="hello_SPI_";   in Tx side 

by using HAL_SPI_TransmitReceive(&hspi1, (uint8_t*)Tx_buffer, (uint8_t*)rx_buffer, size,100);  in re_buffer date is incorrect i getting data is08 05 0C 0C 0F 0F 03 00 09 0F (in hex ) or <\b><5><\f><\f><15><15><3><\0><9><15>(in ASCII).

when i use HAL_SPI_Transmit() & HAL_SPI_Receive() then data in not receive in rx_buffer (both polling and interrupt).

 

Thanks,

Naresh

gbm
Lead III

Start by reading this topic:

https://community.st.com/t5/stm32-mcus-products/regarding-function-calls-when-performing-spi-communication-in/m-p/738412#M265178

 

To get SPI working, use TransmiReceive only. For SPI Master you usually don't need anything else. What's the SPI configuration? What's the SPI clock frequency? I suspect the SCLK if too fast - start by setting it to no more than 1 MHz, verify the correct operation, then try to increase it.

To use _IT functions, SPI interrupt must be enabled in SPI settings, NVIC tab. Still, after you get basic TransmitReceive working, try to use TransmitReceive_IT. Separate Transmit and Receive will not work.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

@Naresh_ wrote:

 i am not use any oscilloscope or logic analyzer.


You should do - how else will you be able to see what's happening on the wires?