How many PWM output channels does the Atmega4809 really have?

How many PWM outputs does the Atmega4809 really have? The Microchip site claims it has 8.

The datasheet for the Atmega4809 microcontroller is split up into two pdfs. This one is for the megaAVR family. It describes the timer configuration for generic timers used in PWM. This one describes a few specifics of the pin layout for the Atmega4809.

For PWM, the Atmega4809 has:

• One 16-bit Timer/Counter type A with dedicated period register, three compare channels (TCA)
• Four 16-bit Timer/Counter type B with input capture (TCB)
• One 16-bit Real Time Counter (RTC) running from external crystal or internal RC oscillator

From what I understand, the one TCA timer has PWM 3 output channels and TCB timers each have only one output channel. That makes 7 PWM output channels. Does that mean the real-time counter (RTC) can be configured as a PWM output?

• Correct. The RTC has a compare match unit. – Tom Carpenter Apr 17 '18 at 22:14

I am not sure where does the number 8 come from, but I can see total of 10 possible PWM outputs in the datasheet.

The RTC has no easy & direct way how to create PWM output.

On the other hand TCA timer can be run in split 8bit mode. Citing from the megaAVR family datasheet, page 193:

Split Mode Overview To double the number of timers and PWM channels in the TCA, a Split mode is provided. In this Split mode, the 16-bit timer/counter acts as two separate 8-bit timers, which each have three compare channels for PWM generation. The Split mode will only work with single-slope down-count. Split mode does not support event action controlled operation.

You can enable this mode by setting bit 0 in CTRLD register. The meaning of CTRLB register changes then and you can enable all 6 outputs there. So, if it is acceptable to have 8bit only PWM with common clock source for all 6 channels, you can use this mode.

Atmega4809 datasheet shows, in page 8, which pins can be outputs of TCA0 mapped to.

TCB timers add 4 PWM channels, one for each counter.

If you really need more PWM channels, it is maybe possible to get one or few more (in a bit hacky way) through the custom logic unit. Use suitable source of periodic events (maybe the RTC?) to flip an output of CCL as needed.

• On page 8, it appears "0-WOn" means TCA0 wave ouput n, where n is from 0 to 5. To select which pins those outputs are connected to, do you use the TCAROUTEA register? – Scampbell Apr 18 '18 at 1:34
• Yes, you can choose particular port in this way (all six TCA outputs have to be pins 0 to 5 of one and the same port always). – Martin Apr 18 '18 at 11:46