Skip to content
George edited this page Jan 3, 2019 · 3 revisions

Timers are particularly useful when a trigger, independent of the CPU, is needed in order to precisely time certain events. These events could be pulses, signals, delays or interrupts. There are currently 2 available timers on the CC430 MCU that are: Timer_0 and Timer_1.

Timer_1, provided by the "timer1a0.h" library contains the following instructions:

timer1a0.start(milisec); //"millisec" are how many milliseconds (up to 2000) until the timer triggers

timer1a0.attachInterrupt(isrTimer); //triggers isrTimer function interrupt when the timer reached "millisec"

timer1a0.stop(); //halts the timer

//Other useful instructions for Timer_1 not found in the library:
if (TA1R == TA1CCR0){...} //returns true when the timer ticked/overflowed/reached its peak determined time in the "milisec"

TA1CTL = TASSEL_1 + MC_1; //resumes/continues the timer where it left off from timer1a0.stop()

TA1CTL |= TACLR; //resets the timer and starts counting from 0 again to "millisec"