1
\$\begingroup\$

In the arduino-tiny core, is it possible to change TIMER_TO_USE_FOR_MILLIS in the sketch itself? I want to be able to leave my arduino-tiny install stock but swap the timers just for one sketch.

I've obviously tried "#define TIMER_TO_USE_FOR_MILLIS 0" but to no effect.

\$\endgroup\$
1
  • \$\begingroup\$ Does it throw an error or warning? \$\endgroup\$
    – jippie
    Jul 3, 2013 at 5:53

1 Answer 1

1
\$\begingroup\$

Looking at the Arduino-Tiny core in the file core_build_options.h the following code appears depending on the processor type:

#define TIMER_TO_USE_FOR_MILLIS 1

That header is then included in all the other parts of the core code so I don't see any possibility to override it directly from your sketch.

I'm not an Arduino user so don't really know recommendations on changing the core libraries but maybe you could change the code in core_build_options.h to get up and running. I noticed it occurs a few times depending on the processor type so make sure you're changing the correct piece of code.

When / if you upgrade the core files you'll lose that change. To make sure you don't forget to update it in the future you could something like the following in your sketch to throw a compiler error if it's not defined as you expect:

#include "correct_path\core_build_options.h" // Not sure if this will be required
#if TIMER_TO_USE_FOR_MILLIS != 0
    #error TIMER_TO_USE_FOR_MILLIS is wrong value
#endif

Depending on the order things are compiled in you also maybe able to change the header file to use something like this that will only set the value if it was previously undefined so the operation will remain the same for other sketches:

#ifndef TIMER_TO_USE_FOR_MILLIS
    #define TIMER_TO_USE_FOR_MILLIS 1
#endif
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.