#include // ********************** // * Global Variables * // ********************** int stage = 0; // Tracks the stage (0-1) of cycle. int speed_reg = 1563; // Value used to continuously increment speed register, int cycles = 0; //will use this as another software counter // ********** // * Main * // ********** void main (void) { BCSCTL1 &= ~(RSEL0 + RSEL1 + RSEL2); //Sets RSELx bits to 000, slowest speed DCOCTL &= ~(DCO0 + DCO1 + DCO2); // Sets DCOx bits to 000, slowest speed WDTCTL = WDT_MDLY_32; // WDT 1s interval timer. This statment // is required even though WDT is not implemented CCTL0 = CCIE; // CCR0 interrupt enabled TACTL = TASSEL_2 + MC_2; // SMCLK, contmode. See TI sample code for description P2DIR = 0x1E; // Init P2.x P2OUT = 0x00; //turn off legs and other outputs P2OUT |= 0x18; // turn off leds (inverse logic) CCR0 = speed_reg; // Set initial timer count register __enable_interrupt(); // Enable global interrupts (Start Timer) _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt (Low power standby) } // *************** // * Functions * // *************** // ***************************************************************************** // // Name : watchdog_timer // // Description : WDT interrupt service routine. Not currently implemented // // ***************************************************************************** #pragma vector=WDT_VECTOR __interrupt void watchdog_timer (void) { } // end void watchdog_timer(void) // ***************************************************************************** // // Name : Timer_A3 // // Description : Timer A0 interrupt service routine // This function occurs whenever CCR0 register reaches 0. (This // register is then incremented inside the isr) Executes // movement based on global dof flag. Increments step and stage // (if necessary). // // **************************************************************************** #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A3 (void) { CCR0 += speed_reg; // Reincrement timer //note that the timer counts down from speed_reg //for 0.5 second cycles = 25 if (cycles==25) { cycles = 0; //this happens at the half second mark if (stage==0) //checks to see which LED is on and off so it can toggle correctly { // write code to activate Tripod A LED // write code to DEactivate Tripod B LED (inverse logic) stage = 1; //lets the CPU know it's now has A on and B off } else { // write code to activate Tripod B LED // write code to DEactivate Tripod A LED (inverse logic) stage = 0; //lets the CPU know that A is off and B is on } } else { cycles = cycles + 1; } } // end of timer_isr