Coder Social home page Coder Social logo

Comments (7)

henriksod avatar henriksod commented on May 23, 2024

+1

from duetimer.

budryerson avatar budryerson commented on May 23, 2024

Count me in!
I start with this framework:

void T3_Handler()
{
    // do something
}

void setup()
{
    Timer3.attachInterrupt( T3_Handler);
    Timer3.start( 500000);   // timer interrupts every 0.5 seconds
}

void loop()
{
    delay( 2000);                  // do something 4 times
    Timer3.setFrequency( 100000);  // set timer to interrupt every 0.1 seconds
    delay( 2000);                  // do something 20 times
    Timer3.setFrequency( 500000);  // set timer back to 0.5 seconds
}

That does not work. In fact, a sketch like this will just seize up like a cheap watch.
So I tried:
Timer3.setFrequency(100000).start()
And I tried:
Timer3.setFrequency(100000); Timer3.start()
And I tried:
Timer3.start(100000);
None of it works!
I want to accelerate a stepper motor.
a) What is going wrong; and
b) What am I supposed to do?

from duetimer.

Shoxx98 avatar Shoxx98 commented on May 23, 2024

+1
got it working with .setfrequency, then doing .start() but this seems rather inefficient.

from duetimer.

ivanseidel avatar ivanseidel commented on May 23, 2024

Maybe setFrequency could call .start at the end automatically. And, if a frequency <= 0 was assigned to the parameter, .stop would be called.

Can anyone test if calling .start works after all?

from duetimer.

iddq avatar iddq commented on May 23, 2024

setFrequency calls TC_Configure which disables clock and interrupts. Although interrupts are re-enabled by setFrequency later, the clock is still disabled which can be enabled by TC_Start.

from duetimer.

Shoxx98 avatar Shoxx98 commented on May 23, 2024

has anyone figured out how to stop the disabling of the clock?
I am messing around with it rn and simply commenting out pTcCh->TC_CCR = TC_CCR_CLKDIS ; in TC_Configure Edit: "makes it stop entirely" -> doesnt do it on its own

from duetimer.

iddq avatar iddq commented on May 23, 2024

You have to recompile libsam after the modification of tc.c

or you can simply change RC by TC_SetRC function.

In both cases, CV, counter value must be checked (see. TC_ReadCV) and if it is greater than RC, you must reset it (see. TC_Start), otherwise the next interrupt occurs only when CV wraps around, which can be several hours depending on the clock setting.

from duetimer.

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.