Timer interrupt routine called immediately all the time.


I am not sure if this is the right place. Let me know and I will remove it.

I am using Atmel Studio 7 and I create a new project from an Arduino sketch.

I then program any of the 16 bit timers to trigger a timer overflow interrupt every second.
Please have in mind that the sketch I am compiling, includes some libraries that make use of the millis() function.

What I see, no matter which of the 16 bit timers I use, is that it overflows without any delay.
Even if I program the 1024 prescaler, no matter what, it will enter the interrupt routine immediately.

Any ideas?


Any code to see?

Unfortunately not now, but it really doesn't have any errors. I was trying for at least a couple of hours yesterday. I think it has something to do with the arduino way of using some other timers (? perhaps?).

I will paste some code later today.

I found the problem.

The init function, called prior to setup, inside main, initializes almost all timer registers.
I was unaware of that, so I was only programming the features I wanted, for example, I needed only the time overflow interrupt, so I was leaving OCCR registers as they were.

Do you know if there are other issues to consider, where arduino handles things automatically and I shouldn't use?


In the init() function is all stuff initialized at start, before setup() function.