Timers accuracy
Posted: Tue Mar 10, 2015 2:16 pm
Hello! I never checked the accuracy of the "Sleeps" functions, but today there was one problem , when I wrote PWM programm
The main problem is that in my understand "chThdSleepMilliseconds(2000);" - its a 2 seconds delay, but in real it was around 1.2 second. Hence the question: its mistake in my code or understanding or poor accuracy in this function? Thx
Code: Select all
Confgi funcion is:
static PWMConfig pwmcfg = {
10000, /* 10kHz PWM clock frequency. */
1000, /* Initial PWM period 100 ms. */
pwmpcb,
{
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_ACTIVE_LOW, pwmc1cb}, // 3nd channel // PA1
{PWM_OUTPUT_DISABLED, NULL}
},
0,
0
};
And "Enable function" is
pwmEnableChannel(&PWMD2, 2, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 5000));
chThdSleepMilliseconds(2000);
pwmDisableChannel(&PWMD2,2);
The main problem is that in my understand "chThdSleepMilliseconds(2000);" - its a 2 seconds delay, but in real it was around 1.2 second. Hence the question: its mistake in my code or understanding or poor accuracy in this function? Thx