2025-03-26 2:08 AM
These's a very strange bug in current verion of STM32G4 HAL library(STM32Cube_FW_G4_V1.6.1) and it took me 2 days to find a workaround.
The problem is:
When normal power on, everything is fine.
When compiler optimization set to -o1, everything is fine.
But if I set complier optimization to -o3, and perform a software reset(__NVIC_SystemReset()), after reset, the HAL function "HAL_SPI_TransmitReceive_DMA" will fail on "HAL_DMA_Start_IT" line.
Since my optimization is set to -o3, I can't dig deeper to find out what exactly happens. And my workaround is individually set stm32g4xx_hal_dma.c file to compile under -o1.
After doing so the problem disappears.
My IDE is uVision V5.41, and ARM Compiler version is V6.22.
2025-03-26 9:16 PM
More details:
My projects is using MCU to collect sensor data, in the main loop I will poll data ready interrupt pin to start spi transmission.
After software reset, the program will at first using synchronized spi transmit and receive to setup sensor, this part is ok with no problem, but after the system enters working state (means poll data ready pin to start spi dma transmission), the first a few data can be received by spi dma, then the function "HAL_SPI_TransmitReceive_DMA" will always fail.
Please somebody help. Thanks in advance.
2025-03-28 4:52 AM - edited 2025-03-28 4:52 AM
Hello @TomZhu
Is your application work fine with the previous version of HAL library?
2025-03-28 10:38 PM
@Saket_Om Thanks for your attention.
I did not test my project under previous version of HAL library, but I can try to do so. Please advise which version is worth tying, thank you!