1

I have the same problem as described on this topic

I needed to set my prescale factor for Timer0 to 1 so I can get a 62.5Khz PWM out of pin 4

My issue is that now the delays() function on my sketches doesn't work correctly. As mentioned also in the above topic, I've changed the MICROSECONDS_PER_TIMER0_OVERFLOW macro on the wiring.c library, but this doesn't fix the delay() function.

I understand I need to fix the micros() function as well, however I'm confused on how to address the problem.

Isn't the Timer0 Interrupt overflowing 64 times faster now? So dividing the micros by 64 shouldn't address the problem

3
  • This question would get better answers if you asked on the Arduino SE. Questions for the Arduino on this website is more for people who want to know the hardware side of the Arduino. I'm to going to vote to migrate this question to the Arduino SE.
    – user23244
    Nov 18 '17 at 18:32
  • 1
    if the timer is counting 64 times faster, then you need to delay for 64 times longer. Nov 18 '17 at 20:00
  • Modifying standard libraries is a bad idea. The answers in your linked question tell you everything you need to know - "The best workaround is to only use millis() for your timing critical functions." If that isn't good enough then write your own delay() and micros() equivalents. Nov 19 '17 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.