2014-06-24 12:04 AM
I'm trying to make reciprocal counter on STM32F4-Discovery.
Concept: 0. Input signal connected to TIM1_Ch1 (PA8) and TIM4_ETR (PE0); 1. TIM1 is clocked from HSE 168MHz, configured to start from external trigger channel1, counts time base; 2. TIM4 is counting input singnal rising fronts - number of Signal pulses. When Signal rises TIM1 starts counting internal pulses (timebase), TIM4 counts external rising fronts. When TIM1_Update occures, enable TIM1_CC1 interrupt - waiting the next rising front. When TIM1_IT_CC1 occures, stop counting and calculate freqency: freq = pulses / (time in TIM1 pulses) * TIM1_frequency; freq = (TIM4->CNT) / (TIM1->CCR1 + TIM1->ARR) * HClkFreq. Reset counters. And now I have some troubles - unstable Frequency result. I think it's becouse I'm using interrupts and stop timers by software. Is there any way to stop timer automatically with input front? I understand the way to get best results is to make minimunim software operations, ideal - only one calculation. #stm32-reciprocal-counter2014-06-24 07:40 AM
Consider using PWM Input rather than Input Capture.
2014-11-26 08:55 AM