2011-07-13 12:19 AM
I have a string of pulses coming in, and i want to measure the period of a pulse. So i have initialize the input capture for the timer, in my case TIM2 CH4.
RCCIC_Configuration(); /* NVIC configuration */ NVICIC_Configuration(); /* Configure the GPIO ports */ GPIOIC_Configuration(); TIM_ICInitStructure.TIM_Channel = TIM_Channel_4; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x0; TIM_ICInit(TIM2, &TIM_ICInitStructure); /* TIM enable counter */ TIM_Cmd(TIM2, ENABLE); /* Enable the CC4 Interrupt Request */ TIM_ITConfig(TIM2, TIM_IT_CC4, ENABLE); but how do i go about starting the time duration measurement when i see a ''1'' at my input and count until another ''1'' appears? #stm32 #pulse #time-duration2011-07-13 05:34 AM
Read the timer registers, and compute a delta time at the clocking frequency?
What's the min/max time between pulses?2011-07-13 06:24 PM
can u elaborate?
which timer registers are u referring to? the time between each pulse should be approximately values in ms. and what do you mean by computing a delta time?2011-07-14 09:46 AM
Well presumably you're going to want to read the CCR registers at some point, because the main timer is going to tick away, and you're looking to ''capture'' an event which it latches.
delta - difference, time between two points, in a tick unit/quantum, that's presumably not a second, but based on a time line measured in TIMCLK periods. For a millisecond, you're going to need to watch the clock, at 72 MHz, your going to blow through the 16-bit resolution in 1 millisecond (72000 ticks). 36 MHz might be viable, but you'll also need to watch/account for when it rolls over.