8000 start() and stop() fix by feilb · Pull Request #21 · ivanseidel/DueTimer · GitHub 10000
[go: up one dir, main page]

Skip to content

Conversation

@feilb
Copy link
Contributor
@feilb feilb commented Jul 2, 2013

Presently, start() and stop() simply enable and disable timer IRQ, but
do not actually start or stop the timer. Further, setFrequency() is,
somewhat counterintuitively, responsible for starting the timer.

The impact of this is that one may set the frequency for, say, 1Hz. At
an arbitrary time later, one might issue the start() command. This will
cause the first interrupt to occur at an arbitrary time after the
start() command has been issued. For example, if start is issued 0.3s
after setFrequency(), the first period will be 0.7s after start() is
issued.

This same behavior occurs when stop() is issued, then start() at an
arbitrary time later.

In order to fix this, I've introduced 3 changes:

  1. setFrequency() no longer starts the timer
  2. start() now uses TC_Start to properly reset the counter value to 0,
    then start the timer
  3. stop() now uses TC_Stop to properly stop the counter when not in use

Presently, start() and stop() simply enable and disable timer IRQ, but
do not actually start or stop the timer. Further, setFrequency() is,
somewhat counterintuitively , responsible for starting the timer.

The impact of this is that one may set the frequency for, say, 1Hz. At
an arbitrary time later, one might issue the start() command. This will
cause the first interrupt to occur at an arbitrary time after the
start() command has been issued. For example, if start is issued 0.3s
after setFrequency(), the first period will be 0.7s after start() is
issued.

This same behavior occurs when stop() is issued, then start() at an
arbitrary time later.

In order to fix this, I've introduced 3 changes:

1. setFrequency() no longer starts the timer
2. start() now uses TC_Start to properly reset the counter value to 0,
then start the timer
3. stop() now uses TC_Stop to properly stop the counter when not in use
ivanseidel added a commit that referenced this pull request Jul 12, 2013
start() and stop() fix
@ivanseidel ivanseidel merged commit c72ccb8 into ivanseidel:master Jul 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0