TIMER0 in wiring.c

Hello

As far as I understand wiring.c there's the TIMER0_OVF_vect implemented and it seems like it's "out of bounds" for me - meaning I should not mess around with that TIMER0_OVF_vect.

I normally use i.e. TIMER0 to check an Input (i.e. a push button which is not debounced) to sort of "debounce" that button (initiate a counter in TIMER0_OVF_vect which checks after a certain time the status of the push button and thus have a simple "debounce function" within that TIMER0_OVF_vect) or especially when I have time critical functions which need action as soon as the event happens

If I'd like to do that I'd have to modify that "TIMER0_OVF_vect" within wiring.c - is my assumption correct?

regards

Hero_123

Other timers are available.

Can you explain what problem you are trying to solve and why you think it is best solved with a timer 0 overflow interrupt?

Have the button debounce function in the main code instead. There is no reason to have it in an interrupt.

Hello arduarn

Thank you for your reply.

Yes, I do know that other timers exist - TIMER1 and TIMER2.
Right I've used TIMER1 for PWM and TIMER2 for other timercontrolled routines, and I could of course shift those routines however my question is - can I use TIMER0 at all and modify it according my needs/purposes?

I'd like to use TIMER0 for example to control a 7-segment display consisting of 6 elements. The elements are hooked up to a portexpander, a decoder and a multiplexer and TIMER0 is responsible for the control.
I've successful done this already in another project which was created using AVRStudio 4.18 and not using Arduino.

regards

Hero_123

You have our permission to do anything you want with Arduino.

Hello jremington

Thank you for your reply.

Of course I could do the debouncing in the main code, but that's not the answer to my question.

regards

Hero_123

jremington:
You have our permission to do anything you want with Arduino.

Thank you very much indeed.

I think the reason people are giving somewhat testy replies, is that you are asserting a level of knowledge that would allow you to find out for yourself by reading the source. Just a guess.

Hero_123:
can I use TIMER0 at all and modify it according my needs/purposes?

Of course, you have the Arduino core sources installed, so you can hack them to your heart's content.

I see two options:

  • Hijack TIMER0 and lose millis() (EDIT: and micros() as well); expect a lot of code in libraries etc. to break if you do this.
  • If the core configuration of TIMER0 for millis() also fits your use case, then piggyback a bit of additional code into the ISR.

Does your button ISR block during debounce (~10ms)? That's not too cool, if so.

I've successful done this already in another project which was created using AVRStudio 4.18 and not using Arduino

Consider a new challenge: do this without modifying the Arduino core, so that others can take advantage of the effort.

arduarn:
Of course, you have the Arduino core sources installed, so you can hack them to your heart's content.

I see two options:

  • Hijack TIMER0 and lose millis() (EDIT: and micros() as well); expect a lot of code in libraries etc. to break if you do this.
  • If the core configuration of TIMER0 for millis() also fits your use case, then piggyback a bit of additional code into the ISR.

Ok, that's what I'd guessed.

aarg:
Does your button ISR block during debounce (~10ms)? That's not too cool, if so.

No, it doesn't; it only checks the status of the button.

Thanks a lot guys.

Consider my question to be answered sufficiently.

Hero_123:
No, it doesn't; it only checks the status of the button.

Then you don't need an interrupt to do it. If you want to end this, just mark the subject