Coming back to electronics after a long break, I am struggling with the basics. I never was a programmer, but have done a little C programming, but for PCs, not chip-level stuff.
Right now, can someone clarify the _BV() thing.
Is this to write to the TCCR, with only the specified bits set ? COM3B1 etc' being substituted at compile time to match the specific uC, with the bit number in the TCCR ?
Is there a corresponding instruction to clear a bit ?
Each bit within a control register (ex, COM3A1) is #defined in the compiler-supplied include files to the number of that bit within the register (ie, a number from 0 to 7). _BV() is a (rather trivial) macro that turns that into a byte with the corresponding bit set (ie, _BV(COM3A1) is the same as (1<<COM3A1) ( << is left-bitshift). | is bitwise or.
Be careful when configuring registers like that - are you certain the registers will start off in the correct state for &= and |= to give the results you want in all cases? If I know what value I want the whole register to be set to, I assign it directly instead of using &= or |= )