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.

Can MSP430FR5849 capture 1MHz signal using timer capture mode?

Other Parts Discussed in Thread: MSP430FR5849

Hello.

I want to measure input pulse duty using timer capture mode on MSP430FR5849.

Max Frequency will be 1MHz and pin assign is P1.2

When I tested the function, I could get a steady value to 500 KHz. However, in the case of 1MHz, I could not get a steady value.

Below is my source code. Please let me know how can I measure 1MHz input frequency.

Thank you.

===============================================================================================

/*
* main.c
*/
#include "main.h"


unsigned int gap_buf[50];
unsigned char index = 0;
unsigned int new_tmr = 0;
unsigned int old_tmr = 0;

unsigned int new_tmr1[50];
unsigned int old_tmr1[50];

void Init_Timer0_A0(void);
int main(void)
{
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

    PJOUT = 0;
    PJSEL0 = BIT4 | BIT5; // For XT1
    PJDIR = 0xFFFF; 
    PM5CTL0 &= ~LOCKLPM5; //GPIO Wake up

    // Configure one FRAM waitstate as required by the device datasheet for MCLK
    // operation beyond 8MHz _before_ configuring the clock system.
    FRCTL0 = FRCTLPW | NWAITS_1;

    // Clock System Setup
    CSCTL0_H = CSKEY >> 8; // Unlock CS registers
    CSCTL1 = DCORSEL | DCOFSEL_4;
    CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set SMCLK = MCLK = DCO,
    // ACLK = VLOCLK
    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;
    CSCTL0_H = 0; // Lock CS registers

    P1SEL0 |= BIT2;
    P1SEL1 &= ~BIT2;
    Init_Timer0_A0();
   __bis_SR_register(GIE);
   while(1)
   {
   }

   return 0;
}

void Init_Timer0_A0(void)
{
    TA1CTL = TASSEL__SMCLK + MC__CONTINUOUS; // SMCLK, contmode
    TA1CCTL1 =CM_1+CCIS_0+CAP+CCIE+SCS;
    TA1CTL &=~TAIFG;

    return;
}


#pragma vector = TIMER1_A1_VECTOR
__interrupt void Timer1_A1_ISR(void)
{
    if(TA1CCTL1 & CCI)
    {
          new_tmr = TA1CCR1;
          gap_buf[index] = new_tmr - old_tmr;
          index++;
          if(index >= 50)
          {
               _no_operation();
               index = 0;
           }
         old_tmr = new_tmr;

         TA1CCTL1 &= ~CCIFG;
         TA1CCR1 = 0;
     }

}

**Attention** This is a public forum