32x: a hack for dealing with pwm inaccuracy

This commit is contained in:
notaz 2013-07-09 03:05:02 +03:00
parent 6a98f03eef
commit bc3aea8e70

View file

@ -52,11 +52,16 @@ void p32x_timers_do(unsigned int cycles)
cycles *= 3; cycles *= 3;
// since we run things in async fashion, allow pwm to lag behind
// but don't allow our "queue" to be infinite
cnt = pwm_smp_expect - pwm_smp_cnt;
if (cnt <= 0 || cnt * pwm_cycles < OSC_NTSC/7*3 / 60 / 2) {
pwm_cycle_counter += cycles; pwm_cycle_counter += cycles;
while (pwm_cycle_counter > pwm_cycles) { while (pwm_cycle_counter > pwm_cycles) {
pwm_cycle_counter -= pwm_cycles; pwm_cycle_counter -= pwm_cycles;
pwm_smp_expect++; pwm_smp_expect++;
} }
}
// WDT timers // WDT timers
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {