2021-01-10 09:38 AM
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.
2021-01-10 10:03 AM
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.
2021-01-10 10:09 AM
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
2021-01-10 09:41 PM
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.