Giter Site home page Giter Site logo

timerone's Introduction

#TimerOne Library

Paul Stoffregen's modified TimerOne. This version provides 2 main benefits:

1: Optimized inline functions - much faster for the most common usage
2: Support for more boards (including ATTiny85 except for the PWM functionality)

http://www.pjrc.com/teensy/td_libs_TimerOne.html

https://github.com/PaulStoffregen/TimerOne

Original code

http://playground.arduino.cc/Code/Timer1

Open Source License

TimerOne is free software. You can redistribute it and/or modify it under the terms of Creative Commons Attribution 3.0 United States License. To view a copy of this license, visit

http://creativecommons.org/licenses/by/3.0/us/

Paul Stoffregen forked this version from an early copy of TimerOne/TimerThree which was licensed "Creative Commons Attribution 3.0" and has maintained the original "CC BY 3.0 US" license terms.

Other, separately developed updates to TimerOne have been released by other authors under the GNU GPLv2 license. Multiple copies of this library, bearing the same name but distributed under different license terms, is unfortunately confusing. This copy, with nearly all the code redesigned as inline functions, is provided under the "CC BY 3.0 US" license terms.

timerone's People

Contributors

aster94 avatar frankboesing avatar george-hawkins avatar ivankravets avatar oyeb avatar paulstoffregen avatar photodude avatar samverstraete avatar stoykodimitrov avatar tomaskovacik avatar tr4nt0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

timerone's Issues

Support for Atmega 328 (not P)

Hello,
Good job on this Timer library. I think you should add support for Atmega328 (not P).
It should be a simple replace in config file

// Uno, Duemilanove, LilyPad, etc
//
#elif defined ( AVR_ATmega168 ) || defined ( AVR_ATmega328 ) || defined ( AVR_ATmega328P )

Cheers,
Calin.
P.S. I write code in arduino studio for Atmega328 and then I use the microcontroller directly for different purposes (without the entire Arduino board). Also because I wanted to use all the pins of my microcontroller I haven't mounted external clock so I have the builtin clock of 8 Mhz.

P.S.S. For some reason git editor does some replacements on underscores. Anyway I think you got the idea :).

Lacking support for pwm pins 0 and 1 on ATTiny85

Description

I've been working on a project using TimerOne's pwm functionality on an Arduino Uno.
Now that the prototype code is working we'd like to downsize our ptototype to an ATTiny85.
However, TimerOne lacks support for the PWM function on an ATTiny85.

I may make an attempt to add this functionality myself at a later date if nobody else figures out how.
Today was my first day working with an Arduino(or C for that matter) in three years so I'm a bit out of practice.

Steps To Reproduce Problem

Attempt to call Timer1.pwm() when programming an ATTiny85

Hardware & Software

Board ATTiny85-20PU
Shields / modules used None
Arduino IDE version 1.8.13
Version info & package name (from Tools > Boards > Board Manager)
Operating system & version Ubuntu 18.04 Budgie
Any other software or hardware? Using Arduino Uno as ISP

Arduino Sketch

NOTE: Sketch will be added once I receive the new set of ATTiny85s

// Change the code below by your sketch (please try to give the smallest code which demonstrates the problem)
#include <Arduino.h>

// libraries: give links/details so anyone can compile your code for the same result

void setup() {
}

void loop() {
}

Errors or Incorrect Output

If you see any errors or incorrect output, please show it here. Please use copy & paste to give an exact copy of the message. Details matter, so please show (not merely describe) the actual message or error exactly as it appears.

Questions

I have some questions.

  1. What is the difference between TimerOne and TimerThree?
  2. Can we rely on the microsecond value of the Timer1.setPeriod(microseconds) function? Is it absolute or approximate?

Timer will not delay for long periods

I tried to use TimerOne to delay for a period of 5 seconds and it did not work. Code below:

#include <TimerOne.h>
bool wait;

void setup() {
  wait = 1;
  Timer1.initialize(0);
  Serial.begin(9600);
  while( ! Serial )
    ;
}

void timerExpired() {
  wait = 0;
}
void loop() {
  Timer1.attachInterrupt(timerExpired, 1000000 * 5);
  Timer1.start();
  Serial.println("Waiting...");
  while( wait )
    ;
  Timer1.detachInterrupt();
  wait = 0;
  Serial.println("Timer expired.");
}

Timer1 hangs delay() function.

I am using an arduino nano
When I use timer1 library, the delay() function belonging to timer 0 hangs the entire code execution.

setPeriod() starts new period with whatever is left over in TCNT1

If a stop() is issued for a running timer, TCNT1 is not cleared and a subsequent setPeriod() will start with the residual initial value.
The following will reproduce the problem

timer1.initialize(3000000); //start a three second timer
delay(2000); //wait 2 seconds
timer1.stop(); //stop timer1
// TCNT1 contains the residual
unsigned long saveStartTime = millis();
timer1.setPeriod(2000000); // set new 2 second timer
TIFR1 = _BV(TOV1); // Be sure overflow flag is cleared
while(!(TIFR1 & TOV1)); // wait for timer overflow
Serial.print("Timer expired at ");
Serial.print(millis() - saveStartTime);
Serial.println(" milliseconds);

Note: the expire interval can be ANY value BUT IT WILL NOT BE 2000 MILLISECONDS!! This is a consequence of the calculation of the prescaler bits.

0 dutycycle not working, gives %100 duty when trying to set 0.

Hi
Firstly,Thanks for your project!
I noticed that, when i want to setpwmduty to 0, it makes dutycycle %100.
I editted your library like that;

void TimerOne::setPwmDuty(char pin, int duty)
{
unsigned long dutyCycle = pwmPeriod;

dutyCycle *= duty;
dutyCycle >>= 10;

if( duty<=0) //newly added line both protection and prevent 0 dutycycle error.
dutyCycle=1;

oldSREG = SREG;
cli();
if(pin == 1 || pin == 9) OCR1A = dutyCycle;
else if(pin == 2 || pin == 10) OCR1B = dutyCycle;
Serial.print(dutyCycle);
SREG = oldSREG;
}

Wrong Output Freq on Teensy 3.2

I believe there is a bug in this library, related to the binary search tree logic in setPeriod().

The logic never sets clockSelectBits to 2, where the previous implementation (commented code) can.

Specific case which can cause incorrect frequency output:

#include <TimerOne.h>

void pulse(void);

void setup() {  
  pinMode(17, OUTPUT);
  Timer1.initialize(1e6/92); // 92 Hertz
  Timer1.attachInterrupt(pulse);
}

void loop() {
}

// create short pulse every interrupt
void pulse(void) {
  digitalWrite(17, LOW);
  delay(1);
  digitalWrite(17, HIGH);
}

The resulting logic probe capture, showing an output frequency of 185 Hz:
timerone-output

This bug seems not to be present when disabling the binary tree optimized code, and using the original version.

Not working on 1284P - have fix

TimerOne is working on 328P AND the 644P but not on 1284P.
I am using the latest TimerOne and Mighty 1284 core.
Tried on IDE 1.0.6 and 1.6.4. with more than one chip.

I noticed a diff in pins between the 644 and 1284.

elif defined(AVR_ATmega644P) || defined(AVR_ATmega644)

#define TIMER1_A_PIN 13
#define TIMER1_B_PIN 12
. . . versis . . .

elif defined(AVR_ATmega1284P)

#define TIMER1_A_PIN 12 // PD5 <<<<<< SB 13?
#define TIMER1_B_PIN 13 // PD4 <<<<<<< SB 12?

I switched 12 and 13 for the 1284 and it's working now.
Hopefully it's a typo and I don't have some kind of bizarro problem :)

Thanks for a great lib and all the work to support so many devices.
John

[Error:] Not Working for the Digispark with Attiny85

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).

Add read() function

Request is here:
https://forum.pjrc.com/threads/34817-Timer1-read()

This needs to be done carefully. If anyone contributes this, please do not copy from the TimerOne fork where the author changed the license to GPL.

How this should work across AVR and 32 bit ARM versions is also a good question. Long-term, I want to allow TimerOne to work on all boards... so care is needed to not inadvertently expose hardware dependent behavior.

Support for ATtiny84/44/24

Hello,

it would be great to have ATtiny84 support. Sometimes Attiny85 is not enough (5 pins) and moving to Attiny84 would be good idea.

Two glitches at start of timer on Teensy 2.0++

Description

On the Teensy 2.0++, the timer library calls the interrupt handler twice immediately after starting, before settling down to the specified rate.

Steps To Reproduce Problem

Start the timer and look at when the timer interrupt is called. See the sketch below.

Expected behavior: the timer should wait the specified interval and then call the timer interrupt periodically.
Observed behavior: the timer interrupt is immediately called twice and then it starts working as expected.

Hardware & Software

Board: Teensy 2.0++
Shields / modules used: none
Arduino IDE version: 1.8.19
Teensyduino version (if using Teensy): 1.56
Version info & package name (from Tools > Boards > Board Manager)
Operating system & version: macOS Monterey 12.3..1 on MacBook Air

Note: I opened issue #55 for a timer problem on the Teensy 3.6. This is a different issue on the Teensy 2.0++.

Arduino Sketch

#include <TimerOne.h>
#define PIN_DEBUG2 7
#define PIN_DEBUG 6

void timerInterrupt() {
  // Generate a debugging pulse
  digitalWriteFast(PIN_DEBUG, HIGH); delayMicroseconds(5); digitalWriteFast(PIN_DEBUG, LOW);
}

void setup() {
  pinMode(PIN_DEBUG, OUTPUT);
  pinMode(PIN_DEBUG2, OUTPUT);
  digitalWriteFast(PIN_DEBUG2, HIGH); delayMicroseconds(5); digitalWriteFast(PIN_DEBUG2, LOW);
  Timer1.initialize(100);
  Timer1.attachInterrupt(timerInterrupt);
}

void loop() {}

Errors or Incorrect Output

In the oscilloscope trace below, the yellow pulse is when setup() is called. The green pulses are when timerInterrupt() is called.

Expected behavior: a green pulse 100 microseconds after the yellow pulse, followed by green pulses every 100 microseconds.
Observed behavior: two green pulses immediately after the yellow pulse, followed by the correct pulses every 100 microseconds.

Oscilloscope trace

External input for the timer1 to generate an interrupt when the counter reaches the maximum

I would like to make a frequency meter for up to 500khz (or more if possible), I would like to try via external input for the timer1 (16 bits, should give a 7 restarts). It seems that it is possible to generate an interrupt when the counter reaches the maximum (when it should restart the count).

I've been looking at the source code, but it seems like there's no such kind of setup, do you have any examples?

Thank you.

Is the TimerOne library not compatible with the GPL license?

Hi,

Would it be possible to modify the license?

GPL, What is it? | It is the most widely used free software license which grants the recipients, rights to copy, modify and redistribute the software and to ensure that the same rights were preserved in all derivative works

Creative Commons License, Compatible with GPL: No
https://www.diffen.com/difference/Creative_Commons_License_vs_GPL

The MIT License is compatible with many copyleft licenses, such as the GNU General Public License (GNU GPL). Any software licensed under the terms of the MIT License can be integrated with software licensed under the terms of the GNU GPL

https://en.wikipedia.org/wiki/MIT_License

PWM on Arduino Micro?

On Arduino Micro:
Basic timer invocation of attached routine seems fine.
Controlling PWM isn't working. Can't make the pins change
value. Isn't this supposed to be like Leonardo?

Errors when using TimerOne with new Arduino Nano Every

Description

I get some errors, so some definitions may need to be added ยฟ? to support new ATMEGA4809.

Steps To Reproduce Problem

Code compiling

Hardware & Software

Board Arduino Nano Every
Shields / modules used
Arduino IDE version 1.8.4
Teensyduino version (if using Teensy)
Version info & package name (from Tools > Boards > Board Manager)
Operating system & version win 8.1
Any other software or hardware?

Arduino Sketch

// Change the code below by your sketch (please try to give the smallest code which demonstrates the problem)
#include <Arduino.h>
#include <TimerOne.h>
// libraries: give links/details so anyone can compile your code for the same result

void setup() {
}

void loop() {
}
    Timer1.initialize(1000);                
    Timer1.attachInterrupt(wave);


### Errors or Incorrect Output
C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::initialize(long unsigned int)':

C:\Users\Rafael\Documents\Arduino\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

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:47:2: note: suggested alternative: 'TCB1'

  TCCR1B = _BV(WGM13);        // set mode as phase and frequency correct pwm, stop the timer

  ^~~~~~

  TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\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 C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:48:2: error: 'TCCR1A' was not declared in this scope

  TCCR1A = 0;                 // clear control register A

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:48:2: note: suggested alternative: 'TCB1'

  TCCR1A = 0;                 // clear control register A

  ^~~~~~

  TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::setPeriod(long unsigned int)':

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:54:25: error: 'CS10' was not declared in this scope

   clockSelectBits = _BV(CS10);

                         ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:54:25: note: suggested alternative: 'CMD10'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:58:25: error: 'CS11' was not declared in this scope

   clockSelectBits = _BV(CS11);

                         ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:58:25: note: suggested alternative: 'CSDV1'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:62:25: error: 'CS11' was not declared in this scope

   clockSelectBits = _BV(CS11) | _BV(CS10);

                         ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:62:25: note: suggested alternative: 'CSDV1'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:62:37: error: 'CS10' was not declared in this scope

   clockSelectBits = _BV(CS11) | _BV(CS10);

                                     ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:62:37: note: suggested alternative: 'CMD10'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:66:25: error: 'CS12' was not declared in this scope

   clockSelectBits = _BV(CS12);

                         ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:66:25: note: suggested alternative: 'CSDV2'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:70:25: error: 'CS12' was not declared in this scope

   clockSelectBits = _BV(CS12) | _BV(CS10);

                         ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:70:25: note: suggested alternative: 'CSDV2'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:70:37: error: 'CS10' was not declared in this scope

   clockSelectBits = _BV(CS12) | _BV(CS10);

                                     ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:70:37: note: suggested alternative: 'CMD10'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:73:25: error: 'CS12' was not declared in this scope

   clockSelectBits = _BV(CS12) | _BV(CS10);

                         ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:73:25: note: suggested alternative: 'CSDV2'

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:73:37: error: 'CS10' was not declared in this scope

   clockSelectBits = _BV(CS12) | _BV(CS10);

                                     ^

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:73:37: note: suggested alternative: 'CMD10'

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:76:2: error: 'ICR1' was not declared in this scope

  ICR1 = pwmPeriod;

  ^~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:76:2: note: suggested alternative: 'ID31'

  ICR1 = pwmPeriod;

  ^~~~

  ID31

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:77:2: error: 'TCCR1B' was not declared in this scope

  TCCR1B = _BV(WGM13) | clockSelectBits;

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:77:2: note: suggested alternative: 'TCB1'

  TCCR1B = _BV(WGM13) | clockSelectBits;

  ^~~~~~

  TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:77:15: error: 'WGM13' was not declared in this scope

  TCCR1B = _BV(WGM13) | clockSelectBits;

               ^

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::start()':

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:84:2: error: 'TCCR1B' was not declared in this scope

  TCCR1B = 0;

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:84:2: note: suggested alternative: 'TCB1'

  TCCR1B = 0;

  ^~~~~~

  TCB1

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:85:2: error: 'TCNT1' was not declared in this scope

  TCNT1 = 0;  // TODO: does this cause an undesired interrupt?

  ^~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:85:2: note: suggested alternative: 'TCB1'

  TCNT1 = 0;  // TODO: does this cause an undesired interrupt?

  ^~~~~

  TCB1

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::stop()':

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:89:2: error: 'TCCR1B' was not declared in this scope

  TCCR1B = _BV(WGM13);

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:89:2: note: suggested alternative: 'TCB1'

  TCCR1B = _BV(WGM13);

  ^~~~~~

  TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:89:15: error: 'WGM13' was not declared in this scope

  TCCR1B = _BV(WGM13);

               ^

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::resume()':

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:95:2: error: 'TCCR1B' was not declared in this scope

  TCCR1B = _BV(WGM13) | clockSelectBits;

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:95:2: note: suggested alternative: 'TCB1'

  TCCR1B = _BV(WGM13) | clockSelectBits;

  ^~~~~~

  TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:95:15: error: 'WGM13' was not declared in this scope

  TCCR1B = _BV(WGM13) | clockSelectBits;

               ^

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::setPwmDuty(char, unsigned int)':

C:\Users\Rafael\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;

             ^~~~~~~~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:105:13: note: suggested alternative: 'TIMERA0'

  if (pin == TIMER1_A_PIN) OCR1A = dutyCycle;

             ^~~~~~~~~~~~

             TIMERA0

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:105:27: error: 'OCR1A' was not declared in this scope

  if (pin == TIMER1_A_PIN) OCR1A = dutyCycle;

                           ^~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:105:27: note: suggested alternative: 'O_CREAT'

  if (pin == TIMER1_A_PIN) OCR1A = dutyCycle;

                           ^~~~~

                           O_CREAT

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::pwm(char, unsigned int)':

C:\Users\Rafael\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); }

             ^~~~~~~~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:114:13: note: suggested alternative: 'TIMERA0'

  if (pin == TIMER1_A_PIN) { pinMode(TIMER1_A_PIN, OUTPUT); TCCR1A |= _BV(COM1A1); }

             ^~~~~~~~~~~~

             TIMERA0

C:\Users\Rafael\Documents\Arduino\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); }

                                                            ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:114:60: note: suggested alternative: 'TCB1'

  if (pin == TIMER1_A_PIN) { pinMode(TIMER1_A_PIN, OUTPUT); TCCR1A |= _BV(COM1A1); }

                                                            ^~~~~~

                                                            TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:114:74: error: 'COM1A1' was not declared in this scope

  if (pin == TIMER1_A_PIN) { pinMode(TIMER1_A_PIN, OUTPUT); TCCR1A |= _BV(COM1A1); }

                                                                          ^

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:122:2: error: 'TCCR1B' was not declared in this scope

  TCCR1B = _BV(WGM13) | clockSelectBits;

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:122:2: note: suggested alternative: 'TCB1'

  TCCR1B = _BV(WGM13) | clockSelectBits;

  ^~~~~~

  TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:122:15: error: 'WGM13' was not declared in this scope

  TCCR1B = _BV(WGM13) | clockSelectBits;

               ^

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::disablePwm(char)':

C:\Users\Rafael\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);

             ^~~~~~~~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:129:13: note: suggested alternative: 'TIMERA0'

  if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);

             ^~~~~~~~~~~~

             TIMERA0

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:129:27: error: 'TCCR1A' was not declared in this scope

  if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);

                           ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:129:27: note: suggested alternative: 'TCB1'

  if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);

                           ^~~~~~

                           TCB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:129:42: error: 'COM1A1' was not declared in this scope

  if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);

                                          ^

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::attachInterrupt(void (*)())':

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:143:2: error: 'TIMSK1' was not declared in this scope

  TIMSK1 = _BV(TOIE1);

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:143:2: note: suggested alternative: 'TIMERB1'

  TIMSK1 = _BV(TOIE1);

  ^~~~~~

  TIMERB1

In file included from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

                 from c:\users\rafael\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/String.h:30,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Print.h:24,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Stream.h:25,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/Client.h:22,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/api/ArduinoAPI.h:29,

                 from C:\Users\Rafael\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.3\cores\arduino/Arduino.h:23,

                 from sketch\MaxDuino_v1.51.ino.cpp:1:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:143:15: error: 'TOIE1' was not declared in this scope

  TIMSK1 = _BV(TOIE1);

               ^

In file included from C:\Users\Rafael\Documents\Arduino\MaxDuino_v1.51\MaxDuino_v1.51.ino:103:0:

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h: In member function 'void TimerOne::detachInterrupt()':

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:150:2: error: 'TIMSK1' was not declared in this scope

  TIMSK1 = 0;

  ^~~~~~

C:\Users\Rafael\Documents\Arduino\libraries\TimerOne/TimerOne.h:150:2: note: suggested alternative: 'TIMERB1'

  TIMSK1 = 0;

  ^~~~~~

  TIMERB1


First cycle after start() is half the specified interval on Teensy 3.6

Description

On the Teensy 3.6, the first timer interrupt happens after half the specified interval. Subsequent interrupts happen at the right time.

Steps To Reproduce Problem

To reproduce, start a timer and measure the time until the first interrupt. The code below reproduces the problem, generating pulses on pin 6.

Hardware & Software

Board: Teensy 3.6
Shields / modules used: none
Arduino IDE version: 1.8.19
Teensyduino version (if using Teensy): 1.56
Version info & package name (from Tools > Boards > Board Manager)
Operating system & version: macOS Monterey 12.3..1 on MacBook Air
Any other software or hardware? Rigol DS1054Z scope

Arduino Sketch

#include <TimerOne.h>

#define PIN_DEBUG 6

void timerInterrupt() {
  digitalWrite(PIN_DEBUG, HIGH);
  delayMicroseconds(50); // Small delay so the pulse shows up on the oscilloscope
  digitalWrite(PIN_DEBUG, LOW);
}

void setup() {
  pinMode(PIN_DEBUG, OUTPUT);
  Timer1.initialize(1000); // Timer should fire every 1000 microseconds
  Timer1.attachInterrupt(timerInterrupt);
  digitalWrite(PIN_DEBUG, HIGH); // Pulse to indicate the timer start time.
  delayMicroseconds(50);
  digitalWrite(PIN_DEBUG, LOW);
  Timer1.start();
}

void loop() {}

Errors or Incorrect Output

In this oscilloscope trace, the first interval is 500 microseconds, while the following intervals are 1 millisecond.
Expected behavior: all intervals are 1 millisecond.

DS1Z_QuickPrint5

I think the underlying cause of the problem is that the timer uses CPWMS mode, which runs the timer up and down. The first interrupt fires after the timer goes up, while subsequent interrupts fire after the timer goes down and then up, which takes twice as long.

Feature Request

Is it possible to make this wotk with the rp2040? that would be awesome :D

TimerOne issue in combination with BMP085 Adafruit driver

Hello Paul,
I am using the TimerOne module in combination with the Adafruit BMP085 Sensor and driver. However when I run the call back function with the read out command for the sensor (bmp.readAltitude()), the program gets stuck. Any other command, e.g. a Serial.print command gets executed w/o any problems. I tried several different BMP085 drivers, all showing the same effect.
Unfortunately, I am not able to debug the issue with the native Arduino IDE.
I am using an Arduino Uno and the IDE shows Version 1.8.13. The little program file is attached below.
Any Idea?
Rbrunni


#include "TimerOne.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>

Adafruit_BMP085 bmp;
// Define altitude variable
volatile float Altitude;

void setup() {
Serial.begin(9600);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}

Timer1.initialize(200000);
Timer1.attachInterrupt(ReadSensorAlt); // Read the altitude value every 200ms
}

void loop() {

Serial.print ("Altitude: ");
Serial.println (Altitude);  

}

void ReadSensorAlt(void)
{
// Read out of Sensor BMP085 does not work. Any other action works with the interrupt function
Altitude = bmp.readAltitude();
}

New release?

Hi Paul,

Any chance you can do a new release with the latest code?
The latest one is from 2015, it would be really nice to be able to update the code from the Arduino IDE.

cyles not calculated correctly if FCPU > 2000000

Description

The Cycles calculation in TimerOne.h line 183 does not work if the FCPU is smaller 2MHz.
As this calculation is only for Integers the calculation will end up being 0.
F_CPU / 2000000 != 0,5
F_CPU / 2000000 = 0

Steps To Reproduce Problem

Use an FCPU of 1MHz

Hardware & Software

Arduino IDE 1.8.3
Board is a diy Arduino clone -> https://github.com/casartar/MacherDaachBadgeFirmware

Arduino Sketch

none

Errors or Incorrect Output

If cycles is 0 the interuppt does not work correctly.

probably flaw of start()

Description

At least on UNO with latest Arduino IDE and lib git version
timer.start() probably not working as seen in sketches developed with older version.
after a timer.stop() a timer.start() immediately calls ISR (not delayed by set interval)

(maybe it is just an undocumented sideeffect of recent version that stop() clears the set interval?)

Steps To Reproduce Problem

modified example shows problem: see below

Hardware & Software

Board UNO
Arduino IDE version
Version info & package name (from Tools > Boards > Board Manager) git version as of 21.Nov.2020
Operating system & version Win7

Arduino Sketch

#include <TimerOne.h>

const int led = LED_BUILTIN;  // the pin with a LED

void setup(void)
{
  pinMode(led, OUTPUT);
  Timer1.initialize(150000);
  Timer1.attachInterrupt(blinkLED); // blinkLED to run every 0.15 seconds
  Serial.begin(9600);
}

int ledState = LOW;
volatile unsigned long blinkCount = 0; // use volatile for shared variables

void blinkLED(void)
{
  Timer1.stop();
  if (ledState == LOW) {
    ledState = HIGH;
    blinkCount = blinkCount + 1;  // increase when LED turns on
  } else {
    ledState = LOW;
  }
  digitalWrite(led, ledState);
  Timer1.start();        //Timer1.initialize(150000); works in sketches w older version of lib
}

void loop(void)
{
  unsigned long blinkCopy;  // holds a copy of the blinkCount
  noInterrupts();
  blinkCopy = blinkCount;
  interrupts();

  Serial.print("blinkCount = ");
  Serial.println(blinkCopy);
  delay(100);
}

Errors or Incorrect Output

not blinking, counter increasing much too fast w/o blink

Compile Error with Updated A-Star 328PB Board Info

I have two machines each with Arduino IDE v1.8.13 but only on one did I allow it to update the board info (I was prompted to so when starting up the Arduino IDE) and I now get a compile error with a very simple sketch:

Sketch

#include <TimerOne.h>           // https://github.com/PaulStoffregen/TimerOne

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Error message:

Compiling sketch...
/Users/rwaddell/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328pb -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_A_STAR_328PB -DARDUINO_ARCH_AVR -DTWBR=TWBR1 -DTWSR=TWSR1 -DTWAR=TWAR1 -DTWDR=TWDR1 -DTWCR=TWCR1 -DTWAMR=TWAMR1 -DTWI_vect=TWI1_vect -DPIN_WIRE_SDA=PIN_WIRE_SDA1 -DPIN_WIRE_SCL=PIN_WIRE_SCL1 -DSPCR=SPCR1 -DSPSR=SPSR1 -DSPDR=SPDR1 -DPIN_SPI_SS=PIN_SPI_SS1 -DPIN_SPI_MOSI=PIN_SPI_MOSI1 -DPIN_SPI_MISO=PIN_SPI_MISO1 -DPIN_SPI_SCK=PIN_SPI_SCK1 -I/Users/rwaddell/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/rwaddell/Library/Arduino15/packages/pololu-a-star/hardware/avr/5.1.0/variants/a-star328pb "-I/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne" /var/folders/nb/2356s9gj6y714v9fzf4hck080000gn/T/arduino_build_409503/sketch/sketch_sep08a.ino.cpp -o /var/folders/nb/2356s9gj6y714v9fzf4hck080000gn/T/arduino_build_409503/sketch/sketch_sep08a.ino.cpp.o
In file included from /Users/rwaddell/Dropbox/Arduino Projects/sketch_sep08a/sketch_sep08a.ino:1:0:
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::setPwmDuty(char, unsigned int)':
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h:244:13: error: 'TIMER1_A_PIN' was not declared in this scope
  if (pin == TIMER1_A_PIN) OCR1A = dutyCycle;
             ^~~~~~~~~~~~
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h:244:13: note: suggested alternative: 'TIMER1A'
  if (pin == TIMER1_A_PIN) OCR1A = dutyCycle;
             ^~~~~~~~~~~~
             TIMER1A
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::pwm(char, unsigned int)':
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h:253: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/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h:253:13: note: suggested alternative: 'TIMER1A'
  if (pin == TIMER1_A_PIN) { pinMode(TIMER1_A_PIN, OUTPUT); TCCR1A |= _BV(COM1A1); }
             ^~~~~~~~~~~~
             TIMER1A
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h: In member function 'void TimerOne::disablePwm(char)':
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h:268:13: error: 'TIMER1_A_PIN' was not declared in this scope
  if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);
             ^~~~~~~~~~~~
/Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne/TimerOne.h:268:13: note: suggested alternative: 'TIMER1A'
  if (pin == TIMER1_A_PIN) TCCR1A &= ~_BV(COM1A1);
             ^~~~~~~~~~~~
             TIMER1A
Using library TimerOne at version 1.1 in folder: /Users/rwaddell/Dropbox/Arduino Projects/libraries/TimerOne 
exit status 1
Error compiling for board Pololu A-Star 328PB.

add support for ATmega1284

Problem : ATmega1284 will not compile
Solution : change in "..config/known_16bit_timers.h"
Line 149 from: #elif defined(AVR_ATmega1284P)
Line 149 to: #elif defined(AVR_ATmega1284P) || defined(AVR_ATmega1284)

It works fine -- thanks for your work ;-)

TCNT1 = 0 causes unwanted interrupt

Every call to start(); appears to fire the interrupt when resetting the timer to zero on the Arduino (AVR).

This seems to have been mentioned in the code:

TCNT1 = 0;      // TODO: does this cause an undesired interrupt?

As a quick and dirty fix, I changed this to reset the timer to 1 instead of zero. This may not work for every application, but it seems like the original TimerOne hosted on google did something similar

https://code.google.com/archive/p/arduino-timerone/downloads

Around line 151, "wait until timer moved on from zero - otherwise get a phantom interrupt"

100% Duty cycle is not completely 100% (see picture)

here are part of the code I am using:

#define FAN_PWM_PIN 9 //9 or 10 for UNO
#define DEFAULT_DUTY_CYCLE 20
float dutyCycle = DEFAULT_DUTY_CYCLE;
void setup(){
  Timer1.initialize(40);  // 40 us = 25 kHz
}

void loop()
{
    Timer1.pwm(FAN_PWM_PIN, (dutyCycle / 100) * 1023);
}

here is a picture of the PWM :

So far I have no idea why it is causing this issue. (not I can dela with that) 

Inverted PWM

Is there an option for inverted PWM?
I have a motor driver that requires an inverted PWM signal of around 32Khz.

timer time is doubled on arduino MEGA R3

I might be missing something here, but it seems pretty straight forward:
I modified the file examples/Interrupt/Interrupt.pde to include a print of the time with micros():
in the function loop I added

Serial.println("blinkCount = " + String(blinkCopy) + " @ " + String(micros()) + "us");

and changed the initialization to 500000 us to make it easier to follow, with Timer1.initialize(500000); in setup.

I'm using the arduino IDE on mac, just to be sure this is not a config issue.

Gists:
code
output

Example (Serial) output: the first blink takes 0.5 seconds, the rest 1.0 seconds.

blinkCount = 0 @ 60us
blinkCount = 0 @ 50516us
blinkCount = 0 @ 101064us
blinkCount = 0 @ 151652us
blinkCount = 0 @ 202236us
blinkCount = 0 @ 252828us
blinkCount = 0 @ 303416us
blinkCount = 0 @ 354004us
blinkCount = 0 @ 404596us
blinkCount = 0 @ 455176us
blinkCount = 1 @ 505768us
blinkCount = 1 @ 556360us
blinkCount = 1 @ 606944us
blinkCount = 1 @ 657532us
blinkCount = 1 @ 708120us
blinkCount = 1 @ 758708us
blinkCount = 1 @ 809300us
blinkCount = 1 @ 859884us
blinkCount = 1 @ 910472us
blinkCount = 1 @ 961056us
blinkCount = 1 @ 1011652us
blinkCount = 1 @ 1062272us
blinkCount = 1 @ 1112892us
blinkCount = 1 @ 1163512us
blinkCount = 1 @ 1214128us
blinkCount = 1 @ 1264752us
blinkCount = 1 @ 1315368us
blinkCount = 1 @ 1365992us
blinkCount = 1 @ 1416612us
blinkCount = 1 @ 1467236us
blinkCount = 2 @ 1517864us
blinkCount = 2 @ 1568480us
blinkCount = 2 @ 1619108us
blinkCount = 2 @ 1669728us
blinkCount = 2 @ 1720352us
blinkCount = 2 @ 1770968us
blinkCount = 2 @ 1821592us
blinkCount = 2 @ 1872220us
blinkCount = 2 @ 1922840us
blinkCount = 2 @ 1973460us
blinkCount = 2 @ 2024076us
blinkCount = 2 @ 2074700us
blinkCount = 2 @ 2125316us
blinkCount = 2 @ 2175940us
blinkCount = 2 @ 2226564us
blinkCount = 2 @ 2277180us
blinkCount = 2 @ 2327804us
blinkCount = 2 @ 2378424us
blinkCount = 2 @ 2429048us
blinkCount = 2 @ 2479668us
blinkCount = 3 @ 2530292us
blinkCount = 3 @ 2580916us
blinkCount = 3 @ 2631544us
blinkCount = 3 @ 2682164us
blinkCount = 3 @ 2732780us
blinkCount = 3 @ 2783404us
blinkCount = 3 @ 2834020us
blinkCount = 3 @ 2884644us
blinkCount = 3 @ 2935264us
blinkCount = 3 @ 2985888us
blinkCount = 3 @ 3036512us
blinkCount = 3 @ 3087128us
blinkCount = 3 @ 3137752us
blinkCount = 3 @ 3188368us
blinkCount = 3 @ 3238992us
blinkCount = 3 @ 3289608us
blinkCount = 3 @ 3340228us
blinkCount = 3 @ 3390852us
blinkCount = 3 @ 3441468us
blinkCount = 3 @ 3492096us
blinkCount = 4 @ 3542712us
blinkCount = 4 @ 3593336us
blinkCount = 4 @ 3643952us
blinkCount = 4 @ 3694576us
blinkCount = 4 @ 3745200us
blinkCount = 4 @ 3795824us
blinkCount = 4 @ 3846448us
blinkCount = 4 @ 3897064us
blinkCount = 4 @ 3947688us
blinkCount = 4 @ 3998304us
blinkCount = 4 @ 4048928us
blinkCount = 4 @ 4099544us
blinkCount = 4 @ 4150164us
blinkCount = 4 @ 4200788us
blinkCount = 4 @ 4251404us
blinkCount = 4 @ 4302032us
blinkCount = 4 @ 4352648us
blinkCount = 4 @ 4403272us
blinkCount = 4 @ 4453892us
blinkCount = 5 @ 4504516us
blinkCount = 5 @ 4555144us
blinkCount = 5 @ 4605760us
blinkCount = 5 @ 4656384us
blinkCount = 5 @ 4707000us
blinkCount = 5 @ 4757624us
blinkCount = 5 @ 4808240us
blinkCount = 5 @ 4858864us
blinkCount = 5 @ 4909488us
blinkCount = 5 @ 4960112us
blinkCount = 5 @ 5010740us
blinkCount = 5 @ 5061356us
blinkCount = 5 @ 5111980us
blinkCount = 5 @ 5162596us
blinkCount = 5 @ 5213220us
blinkCount = 5 @ 5263836us
blinkCount = 5 @ 5314460us
blinkCount = 5 @ 5365084us
blinkCount = 5 @ 5415704us
blinkCount = 5 @ 5466328us
blinkCount = 6 @ 5516948us

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.