STM32U5xx: SPI3 slave fails at 80 MHz
I use OCTOSPI as SPI master and listen via SPI3 as Slave (in SW NCS mode) what was sent from master.
SPI3 Slave fails for clock speed 80 MHz (larger as 54 MHz:(
Symptoms:
- the data bytes on SPI3 slave are wrong (they look like shifted by one bit)
- running my command again results in a hang (polling status seems to fail)
- with OCTALSPI DIV = 3 (53.333 MHz) - all looks fine still
- so, SPI3 can keep up with 54 MHz as a SPI slave
Also realized:
with debug options (-g3, -Og) it fails earlier, already 40 MHz is the fastest I can get. But OK (obvious: with better optimization a faster speed for polling).
I use these conditions:
- QSPI (OCTOSPI in QSPI mode) is the master
- SPI3 is a slave, just using SCK and MOSI (NCS is in SW mode)
- QSPI sends in indirect mode, via "polling" (checking FIFO threshold before to send a new byte)
- SPI3 polls also, its SPI_FLAG_RXP
- both are combined in one SW loop (with polling status)
do
{
*((__IO uint8_t *)data_reg) = *hospi->pBuffPtr;
/* Wait till fifo threshold or transfer complete flags are set to read received data */
status = OSPI_WaitFlagStateUntilTimeout(hospi, (HAL_OSPI_FLAG_FT | HAL_OSPI_FLAG_TC), SET, tickstart, Timeout);
if (status != HAL_OK)
{
break;
}
if (i == 0)
{
/* on first iteration we get CMD and one byte! */
while ( ! __HAL_SPI_GET_FLAG(&hspi3, SPI_FLAG_RXP)) {;}
*(hospi->pBuffPtr - 1) = SPI3->RXDR;
while ( ! __HAL_SPI_GET_FLAG(&hspi3, SPI_FLAG_RXP)) {;}
*hospi->pBuffPtr = SPI3->RXDR;
i = 1;
}
else
{
while ( ! __HAL_SPI_GET_FLAG(&hspi3, SPI_FLAG_RXP)) {;}
*hospi->pBuffPtr = SPI3->RXDR; //XXXX
}
hospi->pBuffPtr++;
hospi->XferCount--;
} while (hospi->XferCount > 0U);
I was expecting to see SPI3 as slave receiver working up to the same speed as OCTOSPI (80 MHz).
But it works only up to 53.333 MHz (but still OK for my purpose, 40 MHz as "regular SPI via OCTOSPI as QSPI).
