This seems to be a very basic question, however I’m clearly missing something.
in the code snippet below the author is trying to set bits WGM12 and CS10 (I think).
However I cannot resolve the compound function bitshift operation.
In the 4th line:
- if CS10 was 0, after bitshifting 1 to the left by 0 then it will be 1. ANDed to the register would result in the CS10 being set.
- But if CS10 were 1 then bitshifting 1 to the left by 1 the result would be 10 (dec 2), AND that back into the Register value and you would set the bit to the left of CS10.
This seems to be a common bit of code. Can someone tell me where I’m going astray?
OCR1A = 15624;
TCCR1B |= (1 << WGM12);
TCCR1B |= (1 << CS10);