I'm curious about the way the Teensy 3.6 handles a change to an outputs PWM value. Specifically, if the program decides the PWM value needs to change and it writes that new value is the current PWM cycle interrupted and the new value started immediately or does it allow the current PWM cycle to complete before the new value takes effect? If it interrupts the current cycle there would tend to be an effect that would tend to cause the net/average PWM value to be a bit higher than expected as follows:
Assume a clock tick equals one PWM count and that the current PWM cycle with a PWM value of 100 begins a count 0. If allowed to proceed to the completion of the cycle the bit would be ON for 100 ticks then OFF for 155 ticks, but if interrupted at a clock value of, say, 100, with a new PWM value of, say, 110, then we could get in effect a single cycle lasting not 255 ticks but 355 ticks with an ON time of 210 equating to the equivalent duty-cycle of 150 for a 255 tick cycle. The average for the two cycle listed above would be 105 so 150 would be much higher.
If, OTH, the PWM cycle is not interrupted and the new value is held until the current cycle ends then the average would work out though there would be a small effect in the timing.
Trying to catch this on a scope is, well, not very easy...
Brian
Assume a clock tick equals one PWM count and that the current PWM cycle with a PWM value of 100 begins a count 0. If allowed to proceed to the completion of the cycle the bit would be ON for 100 ticks then OFF for 155 ticks, but if interrupted at a clock value of, say, 100, with a new PWM value of, say, 110, then we could get in effect a single cycle lasting not 255 ticks but 355 ticks with an ON time of 210 equating to the equivalent duty-cycle of 150 for a 255 tick cycle. The average for the two cycle listed above would be 105 so 150 would be much higher.
If, OTH, the PWM cycle is not interrupted and the new value is held until the current cycle ends then the average would work out though there would be a small effect in the timing.
Trying to catch this on a scope is, well, not very easy...
Brian