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.
This code working as TB0 in Capture mode.
it does not enter in the Interrupt Service Routine.
As I have tested with breakpoint in the IAR
#include <msp430fr2311.h>
#define NUMBER_TIMER_CAPTURES 20
volatile unsigned int timerBcaptureValues[NUMBER_TIMER_CAPTURES];
unsigned int Index = 0;
void Start_Signal();
void Read_Response();
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
P2SEL1 &= ~BIT1;
P2SEL0 |= BIT1;
P2DIR |= BIT1; // set Data Pin to output Direction
P2OUT &= ~BIT1; // Set output to low
__delay_cycles(18000); // low for 18 ms
P2DIR &= ~BIT1;
P2REN |= BIT1;
TB0CTL |= TBSSEL_2 | MC_2 | TBCLR ; // Use SMCLK as clock source, clear TB0R
TB0CCTL0 |= CM_2 | CCIS_0 | CAP | SCS | CCI | CCIE; // Select Input Signal
// Capture rising edge,
// Use CCI0A=SMCLK,
// Synchronous capture,
// Enable capture mode,
// Enable capture interrupt
TB0CTL |= TBSSEL_2 | MC_2 | TBCLR ; // Use SMCLK as clock source, clear TB0R
__bis_SR_register( GIE);
}
// Timer0_B3 CCR0, TB Interrupt Handler
#pragma vector = TIMER0_B0_VECTOR
__interrupt void TIMER0_B0_ISR(void)
{
TB0CCTL0 &= ~CCIFG;
timerBcaptureValues[Index++] = TB0CCR0;
if (Index >= 20)
{
Index = 0;
}
}
I think you want to check out table Table 6-13. Timer0_B3 Signal Connections in the datasheet. You are configuring T0.0 in your code but the input for CCIS_0 for that is the RTC. Is this what you intended? You probably want to be configuring TB0CCTL1 and using pin P1.6 instead if you want to keep using timer0. Otherwise, you can change to use Timer1 and then set up the TB1CCTL2 instead.
#pragma vector = TIMER1_B0_VECTOR
This catches the (TB1) CCR0 interrupt (which you haven't enabled -- and probably don't want to). Try:
#pragma vector = TIMER1_B1_VECTOR
to catch the "everything else but CCR0" interrupt. See also SLASE58A Table 6-2 (vector 0xFFF2).
-------------------------
timerBcaptureValues[Index++] = TB1CCR1;
This isn't the CCR you want. Try:
timerBcaptureValues[Index++] = TB1CCR2;
-------------------------
Also, "Index" should be "volatile"; this isn't causing trouble now but it will eventually.
**Attention** This is a public forum