What is the meaning of
TIFR0 = 1<<TOV0;
Is it means we are writing 1 to TOV0 bit of TIFR0?
What is the meaning of
TIFR0 = 1<<TOV0;
Is it means we are writing 1 to TOV0 bit of TIFR0?
No. That means we are writing 1 to a bit at position TOV0
, while writing 0 to all other bits in TIFR0
register.
<<
is a bitwise shift left operation, which results equals to all bits of the source number, shifted left in their binary representation.
1
is a number where only the first bit (i.e. the bit at position #0
) is set. Therefore 1 << n
moves that bit n
positions left, and gives you a number where only bit #n
is set, but all other bits are cleared.
TOV0
is a macro, which defines the position of bit TOV0
.
Be careful when using simple assignment like that, because it will clear all other bits.
If you want to modify the only bit, you may use a bitwise or:
TIFR0 |= 1<<TOV0;