H743 SPI slave receive not working in circular DMA mode
I try to make two H743 boards communicate each other. The master board sends a chunk (~300Bytes) unregularly and the slave board shall receive it and write it to memory via DMA.
- Interrupt mode working correctly.
- DMA Normal mode working correctly.
- DMA Circular mode returns only zeros.
Is it restricted at all? The source code says:
/* Circular mode restriction:
(+) The DMA circular mode cannot be used when the SPI is configured in these modes:
(++) Master 2Lines RxOnly
(++) Master 1Line Rx
*/So "slave mode" should work. But the HAL_SPI_Receive_DMA() function has following condition:
/* Set the number if data at current transfer */
if (hspi->hdmarx->Init.Mode == DMA_CIRCULAR)
{
MODIFY_REG(hspi->Instance->CR2, SPI_CR2_TSIZE, 0);
}
else
{
MODIFY_REG(hspi->Instance->CR2, SPI_CR2_TSIZE, Size);
}Removing the condition doesn't help either.
The performance is a very important issue for me. So I don't always want to trigger a HAL_SPI_Receive_IT()
Snippets from my code:
stm32h7xx_hal_msp.c:
hdma_spi3_rx.Instance = DMA1_Stream0;
hdma_spi3_rx.Init.Request = DMA_REQUEST_SPI3_RX;
hdma_spi3_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_spi3_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_spi3_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_spi3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_spi3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_spi3_rx.Init.Mode = DMA_NORMAL; //DMA_CIRCULAR NOT WORKING
hdma_spi3_rx.Init.Priority = DMA_PRIORITY_LOW;
hdma_spi3_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
HAL_DMA_Init(&hdma_spi3_rx);Can anybody help me?
- How to make circular DMA Receive in slave mode work?
- If it's not possible, how to trigger another single DMA receive after one transfer is complete? (Once the DMA started, it's busy also in normal mode.
Thanks for responses