# timer5 overflow code

Hi all. I encountered a line of code from some timer examples given by Nick Gammon, at:

https://www.gammon.com.au/forum/?id=11504

The particular line of code I'm trying to understand (how it works) for his "Frequency Counter sketch for Atmega2560" example is:

``````if (TIFR5 & TOV5)
``````

TIFR5 is a timer interrupt flag register for timer 5. I can understand that part.

As for the TOV5 value..... I've read already that TOV5 represents the 'timer overflow' bit of the TIFR5 register. From what I've seen so far in the user manuals, the TOV5 bit is bit0 (right-most bit) of the TIFR5 register.

So the value of TOV5 equal to zero?

And the code: TIFR5 & TOV5 means a bitwise AND operation between TIFR5 and TOV5, so is it a bitwise AND operation between TIFR5 (in binary form) and 00000000 ? Probably not! So thought I'd just ask about this one.

Thanks for helping in advance!!

if (TIFR5 & TOV5) should probably be if (TIFR5 & (1<<TOV5))

DrAzzy:
if (TIFR5 & TOV5) should probably be if (TIFR5 & (1<<TOV5))

DrAzzy !! Thanks very much for your help. Really appreciated!!!!