I guess this is a programming question :-). I'm trying to understand the notation used in the atmel datasheet to describe things like the timer control registers. A particular example is taking about WGM22:0 being set to 1 or 5 or 7. What on earth does that mean? There is a single bit named WGM22 in the TCCR2B register. How can it be anything other than 0 or 1? I assume the :0 on the end is supposed to convey something, but I have no idea what that might be :-). Is there a section in the datasheet that explains the notation? (Because I can't find it if there is :-).
I had a quick search and this popped up: AVR Timers - An Introduction.
Looks like it might answer a few things
2:0 means bits 2 to 0 of the register/value, ie the bottom 3 bits. 7:4 would mean the top 4 bits of a byte value, etc etc.
MarkT:
2:0 means bits 2 to 0 of the register/value, ie the bottom 3 bits. 7:4 would mean the top 4 bits of a byte value, etc etc.
There must be some additional level of abstraction being employed in the case of WGM22 in particular. It is a single bit in one control register, and the WGM21 and WGM20 bits are in a completely different control register. I guess what they mean is that if I were to pretend WGM22,WGM21,WGM20 formed a 3 bit logical value, then I'd want to set it to 5 or 3 or whatever, but that is so peculiar, I sure wish I could find an official atmel document describing their strange and wondrous notation :-).
WGM22:0 means WGM2[2:0] - they've just abbreviated it for convenience (!). They sometimes say "bits 2...0", so not very consistent, but clear enough from context (if you've read most of the datasheet it's pretty obvious what is meant.)
Either that or the conversion to PDF format lost a few special characters?
Claghorn:
I guess what they mean is that if I were to pretend WGM22,WGM21,WGM20 formed a 3 bit logical value, then I'd want to set it to 5 or 3 or whatever, but that is so peculiar, I sure wish I could find an official atmel document describing their strange and wondrous notation :-).
That is exactly what they mean, don't think I've seen it explained anywhere. Looking at some of the tables (like 18-8) makes it pretty clear, though. There's probably some story about how the bits got split between the two registers. It must be a hum dinger, given that TCCR2A bit 2 is unused ... exactly the right place for WGM22