Through my research, I can see that this topic of TimerOne has surfaced in the past for the original Digispark, and has been answered before as well. I'm new to the ATTiny world and have been trying to port my Arduino code to the Pro platform (from an Uno development platform).
My code uses the TimerOne library to implement timer1 in CTC mode and invoke a simple interrupt routine. The main loop refreshes LEDs attached to ports 0-7, and the interrupt fires off every 50mS. Within the ISR, the code reads an external switch status to change which LEDs are illuminated or extinguished. It's pretty straight forward.
The code fails to compile with the following error (I'm linking to the
hardware extended version of TimerOne):
Arduino: 1.5.8 (Mac OS X), Board: "Digispark Pro (Default 16 Mhz)"
In file included from TGPI_sketch_v21.ino:16:0:
/Users/robert/Documents/Arduino/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::setPwmDuty(char, unsigned int)':
/Users/robert/Documents/Arduino/libraries/TimerOne/TimerOne.h:105:13: error: 'TIMER1_A_PIN' was not declared in this scope
if (pin == TIMER1_A_PIN) OCR1A = dutyCycle;
^
/Users/robert/Documents/Arduino/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::pwm(char, unsigned int)':
/Users/robert/Documents/Arduino/libraries/TimerOne/TimerOne.h:114:13: error: 'TIMER1_A_PIN' was not declared in this scope
if (pin == TIMER1_A_PIN) { pinMode(TIMER1_A_PIN, OUTPUT); TCCR1A |= _BV(COM1A1); }
^
/Users/robert/Documents/Arduino/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::disablePwm(char)':
/Users/robert/Documents/Arduino/libraries/TimerOne/TimerOne.h:129:13: error: 'TIMER1_A_PIN' was not declared in this scope
if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);
^
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
The Pro platform differs from the ATTIny85-based Digispark and from the ATmega328-based platforms so I'm wondering if a TimerOne-equivalent library for the Digispark Pro exists?
If not, I can't believe that my problem hasn't been solved before and whether anyone can point me to a good example of how to achieve interrupting the processor every 50mS to read some digital ports. I've honestly searched for a library everywhere with no success.