MSPLife 2 Posted February 27, 2016 Share Posted February 27, 2016 #define IRout BIT0 int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P2DIR &= ~IRout; P2SEL |= IRout; P2SEL2 &= ~IRout; TA1CCTL0 = CM_2 + CCIS_0 + CAP + CCIE + SCS; // Capture on falling edge, CCI0A, interrupt Enable TA1CTL = TASSEL_2 + MC_2 + TACLR + ID_0; // __bis_SR_register(LPM0_bits+GIE); // Go to sleep while waiting for trigger while (true) { } } #pragma vector=TIMER1_A0_VECTOR __interrupt void Timer1A0(void) { __bic_SR_register_on_exit(LPM0_bits); } Hi guys, Below is my program, it's can not detect a falling edge. I set a break point at line "while true", it can not jump to that position. What I was wrong? Thank in advance! Quote Link to post Share on other sites
roadrunner84 466 Posted March 3, 2016 Share Posted March 3, 2016 IIRC there are TWO interrupt vectors associated with the timer, are you using the right one? Also, the timer does have an interrupt of itself, using the TAIE flag. It is off by one clocktick with respect to CCR0 though. Quote Link to post Share on other sites
tripwire 139 Posted March 15, 2016 Share Posted March 15, 2016 Your code works for me if I add the following two lines to the pin setup: P2OUT |= IRout; P2REN |= IRout; That enables the pullup resistor on P2.0 so that when you ground it there's a definite transition from high to low. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.