mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
32x: a hack for dealing with pwm inaccuracy
This commit is contained in:
parent
6a98f03eef
commit
bc3aea8e70
1 changed files with 9 additions and 4 deletions
|
@ -52,10 +52,15 @@ void p32x_timers_do(unsigned int cycles)
|
||||||
|
|
||||||
cycles *= 3;
|
cycles *= 3;
|
||||||
|
|
||||||
pwm_cycle_counter += cycles;
|
// since we run things in async fashion, allow pwm to lag behind
|
||||||
while (pwm_cycle_counter > pwm_cycles) {
|
// but don't allow our "queue" to be infinite
|
||||||
pwm_cycle_counter -= pwm_cycles;
|
cnt = pwm_smp_expect - pwm_smp_cnt;
|
||||||
pwm_smp_expect++;
|
if (cnt <= 0 || cnt * pwm_cycles < OSC_NTSC/7*3 / 60 / 2) {
|
||||||
|
pwm_cycle_counter += cycles;
|
||||||
|
while (pwm_cycle_counter > pwm_cycles) {
|
||||||
|
pwm_cycle_counter -= pwm_cycles;
|
||||||
|
pwm_smp_expect++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WDT timers
|
// WDT timers
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue