codemaster11
Advanced Member level 4
need help with below lines of code
1) TCCR0A = 0;// set entire TCCR0A register to 0.
2) TCCR0B = 0;// set entire TCCR0B register to 0.
understand line 1 & 2 that both registers are set to 0.
but not clear how the CTC mode turn on with code used in line#3. as the entire TCCR0A = 0x00;
for CTC mode WGM01 = 1; but i don't know the default WGM01 bit state. if WGM01 in TCCR0A is 0
then "how the left bits shift operator along with bitwise OR operator change WGM01 = 0 to WGM01 = 1" which is for CTC mode turning on.
same is the case for below line#4 h registers are set to = 0x00;
// turn on CTC mode
3) TCCR0A |= (1 << WGM01);
// Set CS01 and CS00 bits for 64 prescaler
4) TCCR0B |= (1 << CS01) | (1 << CS00);
// enable timer compare interrupt
5) TIMSK0 |= (1 << OCIE0A);
1) TCCR0A = 0;// set entire TCCR0A register to 0.
2) TCCR0B = 0;// set entire TCCR0B register to 0.
understand line 1 & 2 that both registers are set to 0.
but not clear how the CTC mode turn on with code used in line#3. as the entire TCCR0A = 0x00;
for CTC mode WGM01 = 1; but i don't know the default WGM01 bit state. if WGM01 in TCCR0A is 0
then "how the left bits shift operator along with bitwise OR operator change WGM01 = 0 to WGM01 = 1" which is for CTC mode turning on.
same is the case for below line#4 h registers are set to = 0x00;
// turn on CTC mode
3) TCCR0A |= (1 << WGM01);
// Set CS01 and CS00 bits for 64 prescaler
4) TCCR0B |= (1 << CS01) | (1 << CS00);
// enable timer compare interrupt
5) TIMSK0 |= (1 << OCIE0A);