DMA - NDTR - data in memory?
Dear Community,
I'm recently having some trouble with STM32F7 DMA (STM32F767 Nucleo, STM32CubeIDE, some HAL stuff, but using more and more direct register writes & reads).
I'm using timer input capture with circular DMA from timer peripheral to memory, that works so far.
My problem is that I need to read the DMA-asigned memory buffer (internal SRAM) periodically, independent of the timer peripheral or DMA, I cannot use DMA complete interrupts or callbacks (which works reliably with other peripherals).
To find out where the DMA is currently writing I check the NDTR register to get the latest result from the DMA buffer.
Every now and then I had some strange results that made me doubt the NDTR register, as if data has not yet arrived in the assigned memory buffer, but NDTR had already decremented.
Not sure if that still applies (esp. to STM32F7), but my suspicions are supported by this article:
http://www.efton.sk/STM32/gotcha/g20.html
It basically says that NDTR decrements after data was read from the peripheral, not after data arrived in memory.
So I tried turning off the DMA FIFO, then inserting some NOPs after checking NDTR, still I don't get data reliably (although it seems to have improved a little).
My questions are:
1) That a known problem?
2) Is there any way how to make sure data has arrived in the buffer? I couldn't find any DMA status register information. Checking FIFO status - when it was used - caused some long wait times.
3) Could the NOPs be optimized out by the compiler?
4) Any other ideas? :)
Thanks!