cancel
Showing results for 
Search instead for 
Did you mean: 

Hello. I am using STM32L476 nucleo board. I am facing problem in SPI communication.

SNara.2
Associate

I am trying to communicate with a peripheral device through SPI interface using the HAL SPI library functions. But the function is not working properly. It is getting stuck inside the HAL_Delay function. HAL_SPI_Transmit function just executes an empty infinite loop. I am attaching the screenshot of the debug window pointing to where I am getting stuck.0693W000006I7f1QAC.png

3 REPLIES 3

If doing this in a callback be aware that this is under interrupt context and SysTick will need to be able to preempt, and that HAL_SPI_Transmit is a blocking function best not used in an interrupt/callback.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Imen.D
ST Employee

Hello @SNara.2​ ,

Welcome to the STM32 Community :smiling_face_with_smiling_eyes:.

I advise you to review the SPI example available in STM32CubeL4 firmware package, that ensure the data buffer transmission/reception between two boards via SPI using DMA: STM32Cube_FW_L4_V1.16.0\Projects\NUCLEO-L476RG\Examples\SPI\SPI_FullDuplex_ComDMA

You find more details in the readme file and you may update the example according to your needs.

Please mark my answer as best by clicking on the "Select as Best" button if it fully solved your issue. This will help other users find this solution more quickly.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
SNara.2
Associate

Actually the main problem that I am facing is that when I use the HAL_SPI_Transmit() function in small programs that have size less that 2kB, the function works perfectly. But when I include the same function inside the programs with size greater than 20kB, it gives the above mentioned error.