ivanseidel/DueTimer — pull request #21 by feilb (2013-07-02 18:47:12+00:00)
Title: start() and stop() fix

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