Hi all,
The ATmega328PB has three 16-bit timers: TC1, TC3 and TC4.
Each timer has its own control registers, which include the WGM (Waveform Generation Mode) bits. There are four of these (WGM[3:0]), as specified in Table 20-6 in the datasheet. So far so good.
Now, one would expect a standard naming convention for the constants representing these bits, i.e. WGMxy where x is the timer and y is the bit.
That's what we get, for example, for Timer1 in the header file iom328pb.h (comments mine):
#define TCCR1A _SFR_MEM8(0x80) #define WGM10 0 // <=== #define WGM11 1 // <=== #define COM1B0 4 #define COM1B1 5 #define COM1A0 6 #define COM1A1 7 #define TCCR1B _SFR_MEM8(0x81) #define CS10 0 #define CS11 1 #define CS12 2 #define WGM12 3 // <=== #define WGM13 4 // <=== #define ICES1 6 #define ICNC1 7
However, moving along to Timer3 and Timer4, we find that WGM32, WGM42 and WGM43 are not defined at all, while the mysterious WGM44 is defined - value 3.
So... what's going on? Is that just sloppy writing in the header file, or is there a deeper meaning here?
Thanks in advance
P.S. I did not test any code for these timers yet - maybe I'll get to it later today :-)