2006-10-19 08:20 PM
2011-05-17 12:32 AM
hi.
I have to use the INPUT CAPTURE function of timer I use ICAP1 to detect the rising edge of my signal. For what I undestand reading the manual the value of timer counter is stored on TIM_IC1R when the rising event occour. Could anyone let me know if the timer is in free running mode? What is the way to calculate the time elapsed between two rising edge?2011-05-17 12:32 AM
hi,
for wom who are interesting in The ICAP event load the content of free running timer in the ICRx register.2011-05-17 12:32 AM
Input capture is available in all modes, best for measurement of edge distance is ''PWM input'' mode - you get it immediately and the timer is reset at each second edge.
2011-05-17 12:32 AM
hi edison,
what is the configuration that I have to use to do what you say? Have I to configure the timer as pwm ?2011-05-17 12:32 AM
Hi,
if you want to measure pulse width you bettr use PWM input mode.The code for configuring as PWMI is given here.You can find the details about this mode in reference manual. SCU_APBPeriphClockConfig(__TIM01, ENABLE); /* Enable the clock for TIM0 and TIM1 */ TIM_DeInit(TIM1); /* TIM0 Deinitialization */ /* TIM0 Structure Initialization */ TIM_StructInit(&TIM_InitStructure); /* TIM0 Configuration in PWM input Mode */ TIM_InitStructure.TIM_Mode = TIM_PWMI; TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB; TIM_InitStructure.TIM_Prescaler = 0x7F; TIM_InitStructure.TIM_ICAP1_Edge = TIM_ICAP1_EDGE_RISING; TIM_Init (TIM1, &TIM_InitStructure); /* Get the period of the pulse*/ MyPWMIPulse = TIM_GetPWMIPeriod(TIM1);