Tool/software: Code Composer Studio
Hi everyone
I need to capture the frequency of a pin in msp432p401r. I need help in completing my code.
I have defined the input pin as CCIxA: P10.4.
Can you please help me with how I can read the frequency? Should use interrupts? I have brought a snippet of code for your review.
Thanks
#include "msp.h"
/**
* main.c
*/
void main(void)
{
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // stop watchdog timer
/*********************************TIMER_A0******************************/
NVIC_ClearPendingIRQ(TA0_0_IRQn); // Clear any stale status
NVIC_EnableIRQ(TA0_0_IRQn); // Enable TA0_0 in the interrupt controller
TIMER_A0->CTL = TIMER_A_CTL_TASSEL_2 | //Select SMCLK as source for timer
TIMER_A_CTL_ID_3 | //Divide clock by 8 (this yields 6 MHz for the timer clock)
TIMER_A_CTL_MC_2; //Continuous mode
TIMER_A_CTL_CLR ; //Clear timer count
TA0CTL = TAIE; //Timer_A interrupt enable.
TA0CCTL0 = CM_1 + CCIS_0 + CAP; //Capture mode:Rising edge | Capture/compare input select (CCIxA: P10.4) | Capture mode |