cancel
Showing results for 
Search instead for 
Did you mean: 

timer library bug

mtraman
Associate II
Posted on February 15, 2007 at 07:17

timer library bug

2 REPLIES 2
mtraman
Associate II
Posted on May 17, 2011 at 09:36

In the str library, the 91x_tim.c file has a bug.

if the TIM_InitTypeDef structure is used and the timer is initialized like:

/* TIM1 Configuration in PWM Mode */

TIM_InitStructure.TIM_Mode = TIM_PWM;

TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB;

TIM_InitStructure.TIM_Prescaler = 0xFF;

TIM_InitStructure.TIM_Pulse_Level_1 = TIM_HIGH;

TIM_InitStructure.TIM_Period_Level = TIM_LOW;

TIM_InitStructure.TIM_Pulse_Length_1 = 0x0001;

TIM_InitStructure.TIM_Full_Period = 0x0001;

TIM_Init (TIM1, &TIM_InitStructure);

This does not work as the TIM_Init() function assigns:

/* Set the Duty Cycle value */

if ( TIM_InitStruct->TIM_Pulse_Length_1 < 5 )

{

TIM_InitStruct->TIM_Pulse_Length_1 = 4;

}

but leaves TIM_Full_Period as it is. hence, for any TIM_Pulse_Length_1 < 5

timer does not work

Work around:

comment the section which does the assignment

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

Hi tvikram,

FYI

this condition was fixed for pecision reasons. In fact, to garantee a 50% of pulse length we eliminate pulse length and period values less than 4.

But, I agree that it is a limitation that's why we will take it into account in the next revision of library (v1.2).

Think you and best regards,

mirou