I’m using an STM32F103x. I need to count the number of external pulses from a hardware detector, and take a snap shot of the pulse count at a precise frequency of 100,000 kHz.
My current setup uses TIM5 CH2 configured to count the external pulses. This counts the pulses ok. I also use TIM4 as my sampling time base so every 10uS (update interrupt) I read TIM5->CCR2 and calculate the delta and copy it to external SRAM. This consumes 20% of the CPU.
I would like to DMA the TIM5 CCR2 into external SRAM rather than doing it in the TIM4_IRQHandler to save CPU cycles and prevent the sampling experiencing jitter.
If the CCR2 could be reset upon reading it, that would be better than the cumulative value, but that is not as important as reducing the CPU load.
I have attempted to use TIM4 (Master) as the trigger of TIM5 (Slave) but I have not been able to synchronise TIM5 with TIM4 and still count the pulses on TI2. Is this possible?
Alternatively, is it possible to setup one 100,000kHz timer that also counts external pulses?