STM32H7xx - Bug in SPI Driver HAL in larger transmission (32 bytes transmission in one call)
Hi all. I am having an issue with HAL_SPI_TransmitReceive routine under STM32H743. I am using STM32CubeIDE ver 1.10.1. In our setup for STM32H743, it is bare metal (no RTOS). The SPI is in Slave mode. In particular, I am using SPI4 as follows:
Mode: Slave
PE11 = SPI4_NSS
PE12 = SPI4_SCK
PE13 = SPI4_MISO
PE14 = SPI4_MOSI
Data Size = 8 Bits with first bit as MSB bit
Note that the Master is transmitting at 3M baud.
I am using HAL_SPI_TransmitReceive function. It all works fine until the need for receiving 32 bytes in one call as indicated below:
HAL_SPI_TransmitReceive(&hspi4, aTxBuff, aRxBuff, MAX_NUMBYTES_TO_WRITE_EACH_TIME, 5000)
where MAX_NUMBYTES_TO_WRITE_EACH_TIME = 32
I get about half of them and the rest are all zero and the call gets stuck in HAL_SPI_TransmitReceive and never returns.
Note: I saw a post (https://community.st.com/s/question/0D53W00000MfuaASAR/stm32h7xx-serious-bug-in-spi-driver-hal-version-130-170-and-180?t=1677157489831) where another member (@Dub Bartolec) was having a similar problem. The member had discovered a bug on this routine and had noticed it existed in version 1.3.0, 1.7.0 and 1.8.0 in CubeMX. Having seen that post, I got the latest version (ver 1.11.0 ) from ST GitHub (https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Drivers) and replaced my stm32h7xx_hal_spi.c and stm32h7xx_hal_spi.h with that version. It now actually receives the entire 32 bytes and the bytes are valid. However, it does not come out of the HAL_SPI_TransmitReceive routine. The transmitter thinks it needs to send more but TXP is not set so it gets stuck in that loop. I am doing 8 bytes transfers.
Please assist as we are stuck and the rest of the process cannot continue until I get over this communication issue.
Many thanks in advance.
