I need to enable a timer interrupt for a chip, and in the mean time, I am testing the code on Arduino Nano rather than (feed the chip, test the chip)++
.
So as part of the code I have to TIMSK0 |= (1 << OCIE0A);
which works great on the Arduino Nano, but has to be changed to TIMSK
(without the 0) for the ATtiny45.
I was planning to go for something along the line of
#define NANO//Put // in front for the AtTiny45
#ifdef NANO
const char in = A0;
const char out = 3;
const char pwr = 10;
char *timer = &TIMSK0;
#else
const char in = 3;
const char out = 0;
const char pwr = 1;
char *timer = &TIMSK;
#endif
//...
*timer |= (1 << OCIE0A);
So here are my three questions:
- Do #these commands take space on a chip?
- Is a pointer the way to go for this kind of things?
- Am, am I doing it right?