Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Ultrasonic capture echo

$
0
0

Dear everyone,

I am using two methods to capture echo pulse from ultra sonic sensor.

1. I config to capture both rising and falling edge without LPM mode. in ISR, I measured delta time between rising and falling edge.

 TA1CCTL0 |= CM_3 + CCIS_0 + CAP + CCIE;
   //select smclock for timer a source + make ta1ccr0 count continously up + no division
  TA1CTL |= TASSEL_2 + MC_2 + ID_0;

2. I config to use rising Interrupt and go to LMP0 , when a rising edge is detected exit LMP0, I config to detect falling edge so I measure time between to edge and calculate the result.

 

TA1CCTL0 =  CM_1 + CCIS_0 + CAP + CCIE + SCS; // Capture on rising edge, CCIxA, interrupt Enable
TA1CTL = TASSEL_2 + MC_2 + ID_0 + TACLR; //
__bis_SR_register(LPM0_bits+GIE);
TA1CCTL0 = CM_2 + CCIS_0 + CAP + CCIE + SCS;
TA1CTL = TASSEL_2 + MC_2 + ID_0; //
__bis_SR_register(LPM0_bits+GIE); // Go to sleep while waiting for trigger
TA1CTL |= TACLR;
measure = TA1CCR0;

//capture channel 0
#pragma vector=TIMER1_A0_VECTOR
__interrupt void Timer1A0(void)
{
__bic_SR_register_on_exit(LPM0_bits);
}
 

 

 

 

In method 1, I recognized it is perfectly, no errors.

In method 2, I just think this i good methode, but the result was wrong, and some time it can not detect the falling edge.

So please help to explain why do method 2 is wrong? is LPM interrupt take any delay time?


Viewing all articles
Browse latest Browse all 2077

Trending Articles