2024-11-27 03:33 AM - last edited on 2024-11-27 03:41 AM by SofLit
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
if (hspi->State != HAL_SPI_STATE_READY)
{
return HAL_BUSY;
}
2024-11-27 03:39 AM
Please see the Posting Tips for how to properly post source code, and other details required - including your hardware setup:
@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?
2024-11-27 04:27 AM
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
2024-11-27 04:52 AM - edited 2024-11-27 04:58 AM
Start by reading this topic:
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.
2024-11-27 05:00 AM
@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?