Question
F411 LL SPI-DMA callback delay too long
My code is based on LL SPI-DMA example.
The original code does not have chip select, so I use one GPIO pin as CS pin.
/* Start SPI Tx/Rx */
ADC_CS_Low();
/* Enable DMA Channels to start Tx/Rx */
LL_DMA_EnableStream(DMA2, LL_DMA_STREAM_2);
LL_DMA_EnableStream(DMA2, LL_DMA_STREAM_3);
/* Wait for previous Tx/Rx complete bf we send again
*/
while(ub_SPI1_TxComplete != 1) { }
ub_SPI1_TxComplete = 0;
LL_DMA_DisableStream(DMA2, LL_DMA_STREAM_3);
while(ub_SPI1_RxComplete != 1) { }
ub_SPI1_RxComplete = 0;
LL_DMA_DisableStream(DMA2, LL_DMA_STREAM_2);
ADC_CS_High();So the basic steps are:
- CS Low
- Enable Rx stream
- Enable Tx stream
- Wait for Tx/Rx complete signals, which are modified in Tx and Rx callback functions
- Disable Tx/Rx stream
- CS High
I used PicoScope to monitor clock, and CS signal.
I found from CS low to clock start the delay is well below 1 microsecond; while from clock end to CS high, it takes 2 microseconds. It's too long.
I wonder if there is any register value for me to check if Tx and Rx have finished; instead of replying on callback function.
