Re-enabling TX DMA of SPI cause wrong transmit unit (STM32F407ZET6)
I am working on STM32F407ZET6 with DMA+SPI in slave mode. Trying to reset DMA Counter when NSS is high to avoid shifted data transmit.
TX and RX DMA are working on Circular mode.
This is my tx data
typedef struct {
uint8_t InputState[4];
uint8_t reserved1[4];
uint8_t reserved2[4];
uint8_t reserved3[4];
} SyncDataTX;
Inside init function, i did
*((uint32_t*)(txData.InputState)) = 0x11121314;
*((uint32_t*)(txData.reserved1)) = 0x15161718;
*((uint32_t*)(txData.reserved2)) = 0x19202122;
*((uint32_t*)(txData.reserved3)) = 0x23242526;
HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t *)&txData, (uint8_t *)&rxData, sizeof(txData));
Inside interrupt function, i did
__HAL_DMA_DISABLE(&hdma_spi1_rx);
__HAL_DMA_DISABLE(&hdma_spi1_tx);
__HAL_DMA_SET_COUNTER(&hdma_spi1_rx,sizeof(SyncDataTX));
__HAL_DMA_SET_COUNTER(&hdma_spi1_tx,sizeof(SyncDataTX));
__HAL_DMA_ENABLE(&hdma_spi1_rx);
__HAL_DMA_ENABLE(&hdma_spi1_tx);
In the first transaction, I get this, which is correct data:
11121314
15161718
19202122
23242526
In the second transaction, I get this:
12131414
16171811
20212215
24252619
From the third transaction, I start to getting this:
12131423
16171811
20212215
24252619
This happens even only:
__HAL_DMA_DISABLE(&hdma_spi1_tx);
__HAL_DMA_ENABLE(&hdma_spi1_tx);
:thinking_face:I didn't encounter such problem in STM32H750
