Interrupt based time. Adjust tick cost when timer-0 is reconfigured (the time precision affected when timer-0 reconfigured). Keep all time in nanoseconds.

Interrupt based time. Adjust tick cost every 1 minute and when timer-0 is reconfigured (the time precision affected when timer-0 reconfigured). Keep all time in nanoseconds.
This commit is contained in:
Dmitriy
2021-12-23 22:05:21 -05:00
committed by Ron Evans
parent d0633f6228
commit 92150bd1c5
5 changed files with 141 additions and 17 deletions
+6
View File
@@ -179,6 +179,9 @@ func (pwm PWM) Configure(config PWMConfig) error {
avr.TCCR0B.Set(prescaler)
// Set the PWM mode to fast PWM (mode = 3).
avr.TCCR0A.Set(avr.TCCR0A_WGM00 | avr.TCCR0A_WGM01)
// monotonic timer is using the same time as PWM:0
// we must adust internal settings of monotonic timer when PWM:0 settings changed
AdjustMonotonicTimer()
} else {
avr.TCCR2B.Set(prescaler)
// Set the PWM mode to fast PWM (mode = 3).
@@ -714,6 +717,9 @@ func (pwm PWM) Set(channel uint8, value uint32) {
avr.TCCR0A.SetBits(avr.TCCR0A_COM0B1)
}
}
// monotonic timer is using the same time as PWM:0
// we must adust internal settings of monotonic timer when PWM:0 settings changed
AdjustMonotonicTimer()
case 1:
mask := interrupt.Disable()
switch channel {