In that case, Richard, I think that the 16/24-bit extended PWM code posted previously is ready to be used! There are no problems at all for PWM values between 0x0100[00]+1 and 0xFF00[00]-1; keep in mind though than the TOP value of the extended PWM DAC is equal to 0xFF00[00]-1 (and not 0xFFFF[FF]), for the correct calculation of the DAC output gain coefficients (I am using brackets for the possible 24-bit LSB of the PWM values).
Speaking of the asynchronous Timer1 PWM update delay I mentioned above, here are the readings of the Fast Mode PWM stage output of the t861A asynchronous Timer1 (set for 32 MHz clock frequency), where one clock cycle time is equal to 30.7 ns (f=32.6 MHz) and a complete PWM cycle period of 256 cycles is 7.87 µs (f=127KHz). The clock frequency deviation is due to the fact that the AVR internal oscillator is factory calibrated for use at Vdd=3.0V, while the test circuit supply voltage was 5.0V. If it is required, the oscillator can be re-calibrated for 1% accuracy over a wide supply range of 1.8V .. 5.5V.
The Fast Mode PWM was specifically programmed to output the following pulse train pattern, in nine discrete steps (where c is the PWM Compare-Match value loaded to the OCR1A/OCR1B registers, while the TOP counter value was set to 0xFF). The readings captured below were synchronised to Channel 2 (blue trace) that was triggered by positive pulses (of a specific width for each case), while Channel 1 (the yellow trace) was testing the PWM recovery time after setting the PWM value to 0x00 at Step 4.
Step 1. Ch2 = 1c, Ch1 = 1c: Correct.
Step 2. Ch2 = 2c, Ch1 = 2c: Correct.
Step 3. Ch2 = 3c, Ch1 = 3c: Correct.
Step 4. Ch2 = 4c, Ch1 = 0c: Correct.
Step 5. Ch2 = 5c, Ch1 = 5c: WRONG!
Channel 1 should be producing a 5c positive pulse.
Step 6. Ch2 = 6c, Ch1 = Unchanged (5c):
The Ch1 5c positive pulse (that was loaded and should had been produced at the previous step) is present now, delayed by one Timer1 clock cycle.
Step 7. Ch2 = 7c, Ch1 = 7c: Correct.
Step 8. Ch2 = 8c, Ch1 = 254c: Correct.
Step 9. Ch2 = 9c, Ch1 = 1c: Correct.
It is obvious that the PWM value of 0x05 at step 4, loaded right after the PWM value of 0x00 at step 3, takes two Timer1 clock cycles to be produced while every other PWM update that does not follow a previous PWM value of 0x00 takes only one. Clearly, this is a problem for a Sigma-Delta extended PWM loop DAC implementation that is expected to produce a sub-MSB value output.
This is what the t861A Timer1 Overflow ISR Handler test code looks like:
in r4,SREG ; Status Register preservation
push YL
push YH
; Nine-step PWM output sequence
cpi YL,1
brne PC+2
ldi YH,1
cpi YL,2
brne PC+2
ldi YH,2
cpi YL,3
brne PC+2
ldi YH,3
cpi YL,4
brne PC+2
ldi YH,0
cpi YL,5
brne PC+2
ldi YH,5
cpi YL,6
brne PC+2
rjmp _ReloadB
; ldi YH,6
cpi YL,7
brne PC+2
ldi YH,7
cpi YL,8
brne PC+2
ldi YH,-2
cpi YL,9
brne PC+2
ldi YH,1
out OCR1A,YH
_ReloadB: out OCR1B,YL
inc YL
cpi YL,10
brne PC+2
ldi YL,1
; Done
pop YH
pop YL
out SREG,r4 ; Status Register restore
reti
-George
EDIT: Corrections and additions.