Just needed to refresh my memory on timer registers, and whilst doing so noticed something odd in a datasheet, that or I'm being thick...
Page 149 of the Atmega1284P datasheet has the following text in it, and ref the part that relates to the COM2x1:0 bits, I agree - three is inverted output. The part about TOP is defined as 0xFF when WGM2:0 = 3, I don't think I agree. Table 15-8 shows mode 1 as Phase Correct PWM, TOP = 0xFF, which requires the WGM0 bit only set.
In phase correct PWM mode, the compare unit allows generation of PWM waveforms on the OC2x pin. Setting the COM2x1:0 bits to two will produce a non-inverted PWM. An inverted PWM output can be generated by setting the COM2x1:0 to three. TOP is defined as 0xFF when WGM2:0 = 3, and OCR2A when MGM2:0 = 7 (See Table 15-4 on page 154). The actual OC2x value will only be visible on the port pin if the data direction for the port pin is set as output.
Am I mad, or is this a peculiarity of the fact that the 3rd WGM bit resides in TCCRnB whereas WGM1:0 reside in TCCRnA? Surely WGM2:0 = 3 would be mode 3 in which TOP does == 0xFF, but it's Fast PWM, not Phase Correct.
If it is an error, is there an error reporting system for datasheet errors like this?
I thought I spotted another one earlier, but now can't find it... EDIT - just re-seen the other error. MGM bits, they're WGM bits!?