Other Parts Discussed in Thread: MSP430FR6989
I'm trying to count pulses from a 500 kHz square wave signal using the MSP-EXP430FR6989 board. I'm trying to send the square wave as an external clock source to P1.4/TA1.0 which captures on a falling edge and increments the variable "StoredCount" every 100 pulses. For some reason, the pulses aren't being counted because StoredCount always reads 0. Here is the code that I have so far:
#include <msp430.h>
volatile unsigned int StoredCount = 0;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD;
P1DIR &= ~BIT0;
P1SEL0 |= BIT4;
TA1CCR0 = 100;
TA1CCTL0 |= CCIE + CCIS_0 + CM_2 + CAP;
TA1CTL |= TASSEL_0;
_BIS_SR(GIE);
while(1)
{
TA1CTL |= MC1;
while(StoredCount != 1000000);
TA1CTL &= ~MC1;
StoredCount = 0;
TA1R = 0;
}
return 0;
}
#pragma vector = TIMER1_A0_VECTOR
__interrupt void Timer1_A0_ISR (void)
{
StoredCount++;
}
Currently I'm just monitoring the StoredCount variable using the debugger in CCS cloud and StoredCount is always 0 no matter how long I run it for. All of this is part of a larger project to build a frequency, but I'm just having trouble counting pulses from an external signal.
Any help would be greatly appreciated.