In my setup(), I set up a 2 Khz. timer for later use in timing events. The question is, does that timer start to function right away, or only when we enter the loop() portion of the program?
Thanks in advance for any help.
In my setup(), I set up a 2 Khz. timer for later use in timing events. The question is, does that timer start to function right away, or only when we enter the loop() portion of the program?
Thanks in advance for any help.
Depends on how you set it up, but generally the timers start running as soon as the board is powered. Although you might have reset it when you set it up. Can't tell without seeing the code you used.
Maybe you could show us what you're talking about?
jrdoner:
The question is, does that timer start to function right away, or only when we enter the loop() portion of the program?
It would help to know why you are asking that question. You obviously have something specific in mind.
...R
A hardware timer runs when you configure the prescaler to something other than 0.
The reason I am interested in this is that during the setup() routine, I define the 2 Khz. timer, that I will use to generate muy own timing and delays in the program. In this case, I want to create a delay a little further down in the setup() procedure to allow a piece of hardware to get started.
So relatively speaking, my code is just the usaul timer setup process, then some other setup operations below that, then a reliance on the timer to count out 10 ms. while I'm allowing some hardware to respond.
In that case I think the answer to your question is that the timer is running even before setup starts. It gets turned on in the init() function that main() calls before it calls setup().
I your case you can reset it if you'd like at the beginning of setup or at any other point you wish. Or just let it run. It's fully operational at any point in your code other than perhaps class constructors called at global scope.