cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Calculations

zahir
Associate II
Posted on August 08, 2008 at 06:30

Timer Calculations

2 REPLIES 2
zahir
Associate II
Posted on May 17, 2011 at 09:54

Hi

I am a little confused about the calculations for the timer. I do not seem to be able to get a tick less than 0.3ms. Here is the code I have:

TIM_StructInit(&timStruct);

SCU_APBPeriphClockConfig(__TIM01, ENABLE);

TIM_DeInit(TIM0);

TIM_DeInit(TIM1);

timStruct.TIM_Mode = TIM_OCM_CHANNEL_1;

timStruct.TIM_Clock_Source = TIM_CLK_APB;

timStruct.TIM_Clock_Edge = TIM_CLK_EDGE_RISING;

timStruct.TIM_Prescaler = 0;

timStruct.TIM_Pulse_Level_1 = TIM_HIGH;

timStruct.TIM_Pulse_Length_1 = 0x1;

Also, no matter what I set the Pulse length to, the output does not change. The only control I have is the prescaler. I must be missing something, but even having had a read of lots of examples I cannot see what is wrong.

Zahir

amira1
Associate II
Posted on May 17, 2011 at 09:54

Hello zahir,

Could add this instruction : TIM_Init (TIM0, &TIM_InitStructure); in order to initialize the timer peripheral according to the specified parameters in the TIM_InitTypeDef structure. In the case of not put it, all your modifications in the structure will not be taken into account and will be kept in their default values.

Please try it and let me know if it is OK.

Best regards,

mirou.

[ This message was edited by: mirou on 08-08-2008 10:03 ]