SpenceKonde / DxCore

Arduino core for AVR DA, DB, DD, EA and future DU-series parts - Microchip's latest and greatest AVRs. Library maintainers: Porting help and adviccee is available.
Other
189 stars 50 forks source link

Flexible TDC0 PWM #60

Closed SpenceKonde closed 3 years ago

SpenceKonde commented 3 years ago

Make analogWrite() to any of the 4 pins that TCD0 can drive in the current PORTMUX setting flip on the appropriate bit.

What should happen if someone has two PWM outputs running from TCD0 (the maximum it can drive) and then analogWrite()'s a non 0/255 value to a third? a) it turns off an existing output b) it mirrors one of the current pins, changing the output of that pin c) it does nothing

SpenceKonde commented 3 years ago

Done - both pins will output pwm if you don't turn one off with digitalWrite before turning on another. Turned out to be easy to tack on.

Oh, and it statically assigns the pins to channels. You can;t get independent PWM from WOA and WOC (both on WOA) or WOB and WOD (Both on WOB), but you can from other combinations.