2008-02-15 12:48 AM
2008-02-15 12:48 AM
There is a bug in tim.c in the function
TIM_PWMOModeConfig() The pulse width value is increased if the requested value is less than 5 /* Set the Duty Cycle value */ if (XDutyCycle < 5) { XDutyCycle = 4; } This shouldn't be there as it means that the minimum value of PWM can never be set. The next line is: TIMx->OCAR = XDutyCycle - 4; This is also wrong, as 5 needs to be subtracted not 4. I have tested this with timer 3 where the supplied values to the function are 1 for PWM and 0xC0 for frequency giving 125KHz with an on time of about 200nS for an expected on time of 30nS. The library function puts 0 into OCAR and 0xBF into OCBR. Correcting the code as outlined puts 0xFFFC into OCAR and 0xbf into OCBR. This gives 125KHz with 30nS on time as expected. Charles Beal