Skip to main content
SNara.2
Associate
January 10, 2021
Question

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

  • January 10, 2021
  • 3 replies
  • 1507 views

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

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
January 10, 2021

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
ST Technical Moderator
January 10, 2021

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
SNara.2
SNara.2Author
Associate
January 11, 2021

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.