Normal servo library uses timer1 interrupts. There is also a library ServoTimer2 which controls servos by using timer2. But i am interested in controlling them by Timer0. Is there any special trouble to do this, or why I cant find a library for this? Anyone knows if this can be done? I am thinking of opening ServoTimer2 library and rewrite the code to work with timer0, but i just wanted to stop here and ask if it may be impossible to do. Does it bring any bad side effects?
I know mills work with timer0. I dont need them. Maybe a question, how to disable this properly so it wont interfere with my timer0 servo library?
not only the millis(), but also the delay(). I cant imagine the project more than few lines of code, that do not use any timing functions.
What prevent you from using Timer1 and Timer2 for your servos?
Also micros(), delay(), and any library that uses any of those. You can still uses delayMicroseconds() since that use a busy loop.
Once you disable the Timer0 Overflow Interrupt you have disabled millis(), micros(), and delay(). You can't define your own Timer0 Overflow Interrupt because that ISR is already declared in the Arduino core.
Is there no way around this? delaring overflow interrupt would be the key to do is. Is there a way to overwrite the previous definition or some other way around it?
I have access to even more or at least the same accurate timing accessing directly to timer1 registers.
I have read in datasheet for processor atmega328p that those interrupts that has their vector at lower value address, they have higher priority, so they execute before those which are on higher value address. And timer1 is 16bit and i need it for some important other thing - not worth explaining whole thing. So that thing has to be accurate as much as possible, and i have to be able to set servo motor in between too. The problem is Timer2 has highest priority since it is on lowest value address of all timers, and when i drive the motor with it, its interrupts jump in and they delay the interrputs for Timer1, and then my accuracy is lost.
Is there some other way to make Timer2 interrupts not interfere with Timer1 interrupts?
I think you can avoid having the Arduino core define the Timer0 Overflow ISR by defining your own "main()" function and not calling the "init()" function. That will leave most hardware uninitialized. You won't be able to use any Arduino functions or most libraries.