Coder Social home page Coder Social logo

Problem with timers about arduino_stm32 HOT 4 CLOSED

a7o avatar a7o commented on July 26, 2024
Problem with timers

from arduino_stm32.

Comments (4)

stevstrong avatar stevstrong commented on July 26, 2024

What exactly is your application and what exactly is not working?
I made that change because I had an application where there was a problem with the default configuration.

from arduino_stm32.

a7o avatar a7o commented on July 26, 2024

Here's my very simple test sketch:

void setup() {

    Serial.begin(115200);
    while (!Serial) delay(10);
    delay(1000);    

    Serial.println ("Timer setup start");

    Timer2.pause();
    int period = Timer2.setPeriod(10000); // in microseconds
    Timer2.setOverflow(1000);
    Timer2.refresh();
    Timer2.resume();

    Serial.print ("Timer setup end, period="); Serial.println (period);
}

void loop() {
      uint16_t cnt = Timer2.getCount();
      Serial.print("timer2 counter: "); Serial.println(cnt);
      delay (500);
}

With your library, I see that the counter is always 0. After deleting the return statement, the counter changes as expected (up to 1000 and then from 0 again).

from arduino_stm32.

stevstrong avatar stevstrong commented on July 26, 2024

I am not going to enable that line in boards.cpp again.
But I just pushed a commit to solve the issue.

In order to use any timer from now on, one should call

TimerX.init();

This way the timer will be initialized and paused at the same time.

So in your sketch you have to replace
Timer2.pause();
with
Timer2.init();
Please try this and let me know if it works.

from arduino_stm32.

stevstrong avatar stevstrong commented on July 26, 2024

I just tested your sketch modified as suggested and it works, so I will close this now.
Reopen if it does not work for you.

from arduino_stm32.

Related Issues (20)

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.