cancel
Showing results for 
Search instead for 
Did you mean: 

TIM3 input capture mode problem!

mtaisser9
Associate II
Posted on August 26, 2008 at 12:06

TIM3 input capture mode problem!

5 REPLIES 5
mtaisser9
Associate II
Posted on May 17, 2011 at 12:34

Hello!

i try to use the input capture function of timer3.

summary:

timer 3 is used as an up/down counter.

channel 1 + 2 are used to create pwm signals on output pins.

channel 3 should indicate rising edges of an input signal and should store the timer value in CCR3 register.

initialization of channel 3:

Code:

TIM_ICInitStructure.TIM_ICMode = TIM_ICMode_ICAP;

TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;

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(TIM3, &TIM_ICInitStructure);

enabled ITs:

Code:

// TIM IT enable

TIM_ITConfig(TIM3,TIM_IT_CC1, ENABLE);

TIM_ITConfig(TIM3,TIM_IT_CC2, ENABLE);

TIM_ITConfig(TIM3,TIM_IT_CC3, ENABLE);

TIM_ITConfig(TIM3,TIM_IT_Update, ENABLE);

The problem is that when Channel 3 is configured like described above, the channel 1 stops outputting PWM signals.

how could i solve this problem???

mtaisser9
Associate II
Posted on May 17, 2011 at 12:34

adamajames2
Associate II
Posted on May 17, 2011 at 12:34

I am getting this problem too only with Timer 2. Have you worked out a solution yet?

mtaisser9
Associate II
Posted on May 17, 2011 at 12:34

There was an error in the firmware!

stm32f10x_tim.c

function TI3_Config(TIM_TypeDef * ....... line 2431 is:

tmpccer &= CCER_CC1P_Mask & CCER_CC1E_Mask;

and should be:

tmpccer &= CCER_CC3P_Mask & CCER_CC3E_Mask;

#define CCER_CC3E_Mask ((u16)0xFEFF) is also missing!

[ This message was edited by: m.taisser on 26-08-2008 14:13 ]

adamajames2
Associate II
Posted on May 17, 2011 at 12:34

Thanks,

I looked at the library code and my TIx_Config functions look reasonable.

I then went to look at the PWMI_Config function and from what I deduced it seems to need Channel 1 or 2. So I change my code to output my signal on Channel 3:

PWM_TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;

PWM_TIM_OCInitStructure.TIM_Channel = TIM_Channel_3;

PWM_TIM_OCInitStructure.TIM_Pulse = 250;

PWM_TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

TIM_OCInit(TIM2, &PWM_TIM_OCInitStructure);

And to input PWM on Channel 1:

TIM_ICStructInit(&PWM_TIM_ICInitStructure);

PWM_TIM_ICInitStructure.TIM_ICMode = TIM_ICMode_PWMI;

PWM_TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;

PWM_TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;

PWM_TIM_ICInitStructure.TIM_ICSelection=TIM_ICSelection_DirectTI;

PWM_TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;

PWM_TIM_ICInitStructure.TIM_ICFilter = 0x0;

TIM_ICInit(TIM2, &PWM_TIM_ICInitStructure);

And I now still see my PWM signal (On Pin PA2)

Adam