STM32F429ZIT6 SPI Receive Issue
Hi everyone,
I'm currently using the Nucleo F429ZI development board to test SPI Receive, and I've encountered the following two issues:
I use the HAL_SPI_Receive() function, when I config the SPI frequency to a slower rate, I've observed that the CS signal HIGH too early, causing subsequent received data to be incorrectly received.
SPI Freq Config:
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
Code:
/* CS Enable */
GPIOA->ODR &= ~(1<<4);
HAL_SPI_Receive(&hspi1, data_ptr, 1, 1);
/* CS Disable */
GPIOA->ODR |= 0x0010;
(yellow is CS, blue is SPI SCK)

When I config the SPI frequency to a faster rate, the HAL_SPI_Receive() function times out. I've found similar issues and solutions [1].However, due to my requirement for high speed, I can't afford to slowly determine the timeout function. Therefore, I'm currently not using the HAL function and directly controlling the SPI registers to avoid the HAL_SPI_Receive() timeout issue. However, I still encounter issue 1 with the CS signal HIGH too early.
Referring to the RM0090 Manual programming SPI Receive.


Code:
/* CS Enable */
GPIOA->ODR &= ~(1<<4);
/* Enable SPI, SPE = 1 */
SPI1->CR1 |= 0x0040;
/* Check RXNE flag */
if (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE)){
*data_ptr = (uint16_t)hspi->Instance->DR;
*data_ptr += sizeof(uint16_t);
}
SPI1->CR1 &= 0xFFBF;
/* CS Disable */
GPIOA->ODR |= 0x0010;
[1] SPI receive times out due to SPI_FLAG_RXNE not reseting in SPI_EndRxTransaction.
