interrupt(PORT1_VECTOR) P1_ISR(void) { if((P1IFG & BIT3) == BIT3) { // switch pressed if (TACCR0 == 1) { TACCR0 = 0; // disable timer interrupt P1OUT = 0; // disable LED output _BIS_SR_IRQ(4); // enter low power mode 4 } else { TACCR0 = 1; _BIS_SR_IRQ(4); } } P1IFG = 0x00; // clear interrupt flags }
__interrupt void Timer_B1 (void) { timer_periodicCbPtr(); TBCTL &= ~TBIFG; if (pendingTimerStop) { pendingStop = 0; pendingShutdown = 0; pendingTimerStop = 0; pendingStart = 1; _BIS_SR_IRQ(LPM3_bits); } }
void main(void) { WDTCTL = WDTPW + WDTHOLD; // Disable watchdog timer BCSCTL3 |= LFXT1S_2; // Set ACLK to use internal VLO (12kHz) TACTL = TASSEL_1 | MC_1; // TimerA aux clock in UP mode TACCTL0 = CCIE; // Enable interrupt for TACCR0 match // setup switch interrupt P1DIR &= ~BIT3; // as input P1IES |= 0x01; // interrupt on falling edge P1IE |= BIT3; // interrupt enable eint(); // Enable interrupts TACCR0 = 0; _BIS_SR_IRQ(4); // enter low power mode 4 }
static void ISR_timer0_a1() { _BIC_SR(GIE); switch(TAIV) { case 0x02: clear_pin(PWM_PINS[current_servo]); if(current_servo == 0) { TA0CCR0 = last_period; } else { TA0CCR0 = norm_period; } break; default: break; } _BIS_SR_IRQ(GIE); }
void ISR_timer0_a0() { _BIC_SR(GIE); current_servo++; if(current_servo == NUM_SERVOS) { current_servo = 0; } set_pin(PWM_PINS[current_servo]); /* * If the control structure is not locked, go ahead and access it * (Also access if there was no busy query function specified) */ if(!servo_ctl_busy || !servo_ctl_busy()) { current_servo_pos = servo_ctl->pos[current_servo]; servo_ctl_buffer.pos[current_servo] = current_servo_pos; memcpy(&servo_ctl_buffer.baseband, &servo_ctl->baseband, 4); } else { current_servo_pos = servo_ctl_buffer.pos[current_servo]; } // Clamp servo position uint16_t maxband_diff = servo_ctl_buffer.maxband - servo_ctl_buffer.baseband; if(current_servo_pos > maxband_diff) current_servo_pos = maxband_diff; TA0CCR1 = servo_ctl_buffer.baseband + current_servo_pos; _BIS_SR_IRQ(GIE); }