This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR2311: Do not enter interrupt by giving an input logic high

Part Number: MSP430FR2311

Tool/software:

I am using the FR2311 to drive the Ultrasonic sensor, the output from sensor will be loaded into Port2.1. The input pulse can be captured by oscilloscope. Debugging in CCS.

But I cannot enter the interrupt and I have checked many times about the configurations. Below is the code:

 
#include <msp430.h>
unsigned int capture_up = 0;
unsigned int capture_down = 0;
char capture_number = 0;
char state = 0x00;
unsigned long distance_in_CM = 0;


void Ultrasonic_trig(){
P2OUT |= BIT0;
__delay_cycles(8); // delay to generate the pulse
P2OUT &= ~BIT0;
}


int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
P2OUT &= ~BIT0; // P2.0 no output for start
P2DIR |= BIT0; // P2.0 output
P2SEL0 |= BIT1; // P2.1 options select,

PM5CTL0 &= ~LOCKLPM5;

TB1CTL = TBSSEL__SMCLK | ID_0 | MC_2 | TBCLR | TBIE;
TB1CCTL1 = CM_1 | CCIS_1 | SCS | CAP | CCIE;

__bis_SR_register(GIE);

while (1){
Ultrasonic_trig();
__delay_cycles(80000); // delay 
}
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER1_B1_VECTOR
__interrupt void Timer1_B1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER1_B1_VECTOR))) Timer1_B1_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(TB1IV,TB1IV_TBIFG))
{

case 0:break; // No interrupt
case 2:
state = TB1CCTL1 >> 14;
TB1CCTL1 &= ~CCIFG; //clear flag
if( TB1CCTL1 & CM_1){ //start capture high voltage on raising edge
capture_up = TB1CCR1;
TB1CCTL1 &= ~CM_1;
TB1CCTL1 |= CM_2;
}else if ( TB1CCTL1 & CM_2){ 
capture_down = TB1CCR1;
distance_in_CM = ( capture_down - capture_up ) * 0.34/2; 
TB1CCTL1 &= ~CM_2;
TB1CCTL1 |= CM_1;
}else
break; // CCR1 not used
case 4:break; // CCR2 not used
case 6: break; // reserved
case 8: break; // reserved
case 10: break; // reserved
case 12: break; // reserved
case 14:
TB1CTL &= ~TBIFG;
if(capture_down < capture_up ){
capture_number ++;
}
break; // overflow
default: break;
}
}

**Attention** This is a public forum