Hello,
I'm using an MSP430F5342 to capture the 16 bit timer A value at 2 different instances which are separated from each other by a few hundred milliseconds. Both captures are triggered respectively by input signals on the Pins 1.3 and 1.4, which i've internally pulled up using software.
I want to test the signal using a simple monoshot input on both pins 1.3 and 1.4.
1) The first issue is - How do i associate the ISR with the particular capture, i.e, i want the first ISR (A0) to be called when CCR0 receives a capture, and the second ISR (A1) to be called when CCR1 gets its capture.
2) The second issue is - I am unsure whether increment the variable 'i' to get the actual value of the timer is the correct way to do it.
3) Im sure there are multiple other issues with the code, so even little bits of information could help.
#include <msp430.h>
double a = 0;
double b = 0;
double i =0;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; //Disable Watchdog Timer
P1DIR = 0x03; //Output on Pins 1.0 & 1.1
P1REN = 0x18; //Pullup pins 1.3 & 1.4
P1SEL = 0x18; //Special Pin function for 1.3 & 1.4
TA0CCTL2 = CM_2 + CCIS_0 + SCS + CAP + CCIE; //Setting up Capture on falling edge, Synchronous Capture, and Interrupt Enable for both registers
TA0CCTL3 = CM_2 + CCIS_0 + SCS + CAP + CCIE;
TA0CTL = TASSEL_1 + MC_2; //Continuous Mode and ACLK Source (32kHz)
__bis_SR_register(LPM0_bits + GIE); //LPM0 and General Interrupt Enable
i++; //Incrementing variable for true timer value
while(1);
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR()
{
a = TA0R + (i*65535); // True Timer Value
P1OUT ^= 0x01; // Toggle Output Pin 1.0 to indicate capture
TA0CCTL2 &= ~(CCIFG); // Clear Flag
}
#pragma vector=TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_ISR()
{
b = TA0R + (i*65535); // True Timer Value
P1OUT ^= 0x02; // Toggle Output Pin 1.1 to indicate capture
TA0CCTL3 &= ~(CCIFG); // Clear Flag
}
Thanks in advance :-D