PaulStoffregen / TimerOne

TimerOne Library with optimization and expanded hardware support
http://www.pjrc.com/teensy/td_libs_TimerOne.html
470 stars 209 forks source link

[Error:] Not Working for the Digispark with Attiny85 #42

Closed hasenradball closed 4 years ago

hasenradball commented 4 years ago

Description

Compilation not possible for Digispark (Attiny85)

Steps To Reproduce Problem

Example does not work

Hardware & Software

Board: Digispark

Arduino IDE: 1.8.9

Arduino Sketch

#include <Arduino.h>
#include <TimerOne.h>

#ifndef nullptr
#define nullptr NULL
#endif

// Deifne PINs
#define SENSOR_PIN  1
#define LED_PIN     3

boolean task_trigger{false};

// ============================================
// ### --- START: Klassen Instanzen --- ###
// ============================================

// ============================================
// ### --- ENDE: Klassen --- ###
// ============================================

void task_5000ms(void) {
  task_trigger = true;
}

// ============================================
// ### --- START: Setup --- ###
// ============================================

void setup() {
  // LED
  pinMode(LED_PIN, OUTPUT);

  Timer1.initialize(5000000);
  Timer1.attachInterrupt(task_5000ms);

}

// ============================================
// ### --- ENDE: Setup --- ###
// ============================================

// ============================================
// ### --- START: Main Loop --- ###
// ============================================

void loop() {
  if (task_trigger) {
    task_trigger = false;
    digitalWrite(LED_PIN, LOW);

  }

}
// ============================================
// ### --- ENDE: Main Loop --- ###
// ============================================

Errors or Incorrect Output

In file included from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:2:0: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::initialize(long unsigned int)': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:47:2: error: 'TCCR1B' was not declared in this scope TCCR1B = _BV(WGM13); // set mode as phase and frequency correct pwm, stop the timer ^ In file included from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/io.h:99:0, from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/interrupt.h:38, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/WProgram.h:8, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/Arduino.h:4, from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:1: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:47:15: error: 'WGM13' was not declared in this scope TCCR1B = _BV(WGM13); // set mode as phase and frequency correct pwm, stop the timer ^ In file included from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:2:0: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:48:2: error: 'TCCR1A' was not declared in this scope TCCR1A = 0; // clear control register A ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::setPeriod(long unsigned int)': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:76:2: error: 'ICR1' was not declared in this scope ICR1 = pwmPeriod; ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:77:2: error: 'TCCR1B' was not declared in this scope TCCR1B = _BV(WGM13) | clockSelectBits; ^ In file included from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/io.h:99:0, from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/interrupt.h:38, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/WProgram.h:8, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/Arduino.h:4, from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:1: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:77:15: error: 'WGM13' was not declared in this scope TCCR1B = _BV(WGM13) | clockSelectBits; ^ In file included from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:2:0: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::start()': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:84:2: error: 'TCCR1B' was not declared in this scope TCCR1B = 0; ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::stop()': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:89:2: error: 'TCCR1B' was not declared in this scope TCCR1B = _BV(WGM13); ^ In file included from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/io.h:99:0, from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/interrupt.h:38, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/WProgram.h:8, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/Arduino.h:4, from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:1: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:89:15: error: 'WGM13' was not declared in this scope TCCR1B = _BV(WGM13); ^ In file included from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:2:0: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::resume()': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:95:2: error: 'TCCR1B' was not declared in this scope TCCR1B = _BV(WGM13) | clockSelectBits; ^ In file included from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/io.h:99:0, from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/interrupt.h:38, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/WProgram.h:8, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/Arduino.h:4, from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:1: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:95:15: error: 'WGM13' was not declared in this scope TCCR1B = _BV(WGM13) | clockSelectBits; ^ In file included from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:2:0: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::setPwmDuty(char, unsigned int)': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:105:13: error: 'TIMER1_A_PIN' was not declared in this scope if (pin == TIMER1_A_PIN) OCR1A = dutyCycle; ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::pwm(char, unsigned int)': /mnt/arduinoSketch/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); } ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:114:60: error: 'TCCR1A' was not declared in this scope if (pin == TIMER1_A_PIN) { pinMode(TIMER1_A_PIN, OUTPUT); TCCR1A |= _BV(COM1A1); } ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:122:2: error: 'TCCR1B' was not declared in this scope TCCR1B = _BV(WGM13) | clockSelectBits; ^ In file included from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/io.h:99:0, from /home/frank/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/avr/interrupt.h:38, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/WProgram.h:8, from /home/frank/.arduino15/packages/digistump/hardware/avr/1.6.7/cores/tiny/Arduino.h:4, from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:1: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:122:15: error: 'WGM13' was not declared in this scope TCCR1B = _BV(WGM13) | clockSelectBits; ^ In file included from /mnt/arduinoSketch/Digispark/Digispark_TimerOne_Test/Digispark_TimerOne_Test.ino:2:0: /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::disablePwm(char)': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:129:13: error: 'TIMER1_A_PIN' was not declared in this scope if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1); ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:129:27: error: 'TCCR1A' was not declared in this scope if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1); ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::attachInterrupt(void (*)())': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:143:2: error: 'TIMSK1' was not declared in this scope TIMSK1 = _BV(TOIE1); ^ /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::detachInterrupt()': /mnt/arduinoSketch/libraries/TimerOne/TimerOne.h:150:2: error: 'TIMSK1' was not declared in this scope TIMSK1 = 0; ^ Bibliothek TimerOne in Version 1.1 im Ordner: /mnt/arduinoSketch/libraries/TimerOne wird verwendet exit status 1 Fehler beim Kompilieren für das Board Digispark (Default - 16.5mhz).

aleroy commented 4 years ago

This looks like the same error I got. It turned out to be a real palmface. (or facepalm ... or both).

In your Arduino IDE, goto Tools->Processor and make sure you have "ATtiny85" selected.