cancel
Showing results for 
Search instead for 
Did you mean: 

INPUT CAPTURE

Posted on October 20, 2006 at 05:20

INPUT CAPTURE

5 REPLIES 5
Posted on May 17, 2011 at 09:32

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?

Posted on May 17, 2011 at 09:32

hi,

for wom who are interesting in

The ICAP event load the content of free running timer

in the ICRx register.

tomas23
Associate II
Posted on May 17, 2011 at 09:32

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.

Posted on May 17, 2011 at 09:32

hi edison,

what is the configuration that I have to use to

do what you say?

Have I to configure the timer as pwm ?

nanuradha
Associate II
Posted on May 17, 2011 at 09:32

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);