Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 1 of 1

Thread: How to use TimerOne Library with Arduino Uno WiFi Rev2

  1. #1
    Junior Member
    Join Date
    Sep 2020
    Posts
    1

    How to use TimerOne Library with Arduino Uno WiFi Rev2

    I was an experienced ANSI C programmer in the past but a complete newby for Arduino (my former Job is my new Hobby now :-))

    I'm a proud owner of an Arduino Uno WiFi Rev2 and try to use the TimerOne library since it seems to do exactly what I need (Timer Interrupt and PWM Functionality) but run into some compiling issues.
    I guess that is related to the fact that the CPU is different to the standart Arduino Uno one but I was told that they are "completely" compatible...

    Questions:
    What do I have to do to compile that library?
    Are there alternatives I could use instead?


    Here is my code:

    // definitions for Timer Interrupt handling
    #define TIMER1_ONE_SECOND 1000000
    #include "TimerOne.h"

    void TimerHandler1(void)
    {
    Serial.println("Tick"); // do "something" for the start
    }

    void setup()
    {
    //************************************************** *************
    // Initialize Timer 1
    //************************************************** *************
    Timer1.initialize(TIMER1_ONE_SECOND); // initialize timer1, and set a 1 second period
    Timer1.attachInterrupt(TimerHandler1); // attaches callback() as a timer overflow interrupt
    }

    void loop()
    {
    }

    Here is what I see when I try to compile it (just the start, there is a whole lot of that errors)

    ARNUNG: Bibliothek TimerOne-1.1 behauptet auf avr Architektur(en) ausgeführt werden zu können und ist möglicherweise inkompatibel mit Ihrem derzeitigen Board, welches auf megaavr Architektur(en) ausgeführt wird.
    In file included from C:\Users\User\Documents\Arduino\my sketches\my_first_project_work\my_first_project_wo rk.ino:38:0:
    C:\Program Files (x86)\Arduino\libraries\TimerOne-1.1/TimerOne.h: In member function 'void TimerOne::initialize(long unsigned int)':
    C:\Program Files (x86)\Arduino\libraries\TimerOne-1.1/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:\Program Files (x86)\Arduino\libraries\TimerOne-1.1/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\user\appdata\local\arduino15\packages\ard uino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,
    from c:\users\user\appdata\local\arduino15\packages\ard uino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
    from C:\Users\User\AppData\Local\Arduino15\packages\ard uino\hardware\megaavr\1.8.6\cores\arduino/api/String.h:31,
    from C:\Users\User\AppData\Local\Arduino15\packages\ard uino\hardware\megaavr\1.8.6\cores\arduino/api/Print.h:24,
    from C:\Users\User\AppData\Local\Arduino15\packages\ard uino\hardware\megaavr\1.8.6\cores\arduino/api/Stream.h:25,
    from C:\Users\User\AppData\Local\Arduino15\packages\ard uino\hardware\megaavr\1.8.6\cores\arduino/api/Client.h:22,
    from C:\Users\User\AppData\Local\Arduino15\packages\ard uino\hardware\megaavr\1.8.6\cores\arduino/api/ArduinoAPI.h:29,
    from C:\Users\User\AppData\Local\Arduino15\packages\ard uino\hardware\megaavr\1.8.6\cores\arduino/Arduino.h:23,
    from sketch\my_first_project_work.ino.cpp:1:
    C:\Program Files (x86)\Arduino\libraries\TimerOne-1.1/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
    .....

    The whole list of error ends with:
    C:\Users\User\AppData\Local\Arduino15\packages\ard uino\hardware\megaavr\1.8.6\cores\arduino\UNO_comp at.cpp:20:2: warning: #warning "ATMEGA328 registers emulation is enabled. You may encounter some speed issue. Please consider to disable it in the Tools menu" [-Wcpp]
    #warning "ATMEGA328 registers emulation is enabled. You may encounter some speed issue. Please consider to disable it in the Tools menu"
    Last edited by KarstenA; 09-17-2020 at 11:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •