2021-11-18 11:28 PM
Hello,
I'm using an STM32F767 to measure input frequencies, using 2 timers.
It's a bit tricky because these measurements must be synced to the SAI's audio sampling rate, AND input frequencies can be higher than the audio sampling rate.
It took me a while to figure out how to set up the timers to get there:
TIM3:
TIM4:
From TIM3 I get the time of the latest input event (CCR1) within an audio sample (overcapture flag is willingly ignored in case of input freq > sampling rate),
from TIM4 I get the number of input events (CNT) from an audio sample.
So far so good, it works, that way I can measure input freq. with the timers' resolution, synced to the audio - most of the time...
BUT there's a problem in TIM3 with the IC / CCR1 to DMA:
Sometimes at input freq. > sampling rate when an input event happens very shortly after the audio sampling rate's counter reset and the DMA trigger, it seems that the DMA access to the CCR1 register comes too late, so that not the latest event of the last sample is captured, but already the first event of the new sample after the CNT reset.
Example:
So I have checked the manuals & datasheets about any DMA timer specs and did not find anything.
Any explanations or ideas how to prevent that?
PS: I'm checking the STM32F7 to replace an existing FPGA design, and this is the first real problem...
2021-11-24 08:34 AM
Yeah, maybe working with the DMA's NDTR register.
Sampling rate to a) reset timer, and b) IRQ to check latest CCR-DMA values and the NDTR register. Should not take too much CPU time.
Maybe I was thinking too much FPGA-parallelism... and have not enough MCU experience!
Thanks again @Community member !