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.

MSP430FR5969: Configure external clock

Part Number: MSP430FR5969

Hi experts,

Do we have any sample code to configure external clock as 1MHz in MSP430FR5969? If yes please give me that link.

  • Hi Manish,

    you can find examples for this specific device in TI  Resourse Explorer

    Below a link to an example:

    LINK

    Please check also the additional CS examples for this device for more info.

    Depending on your external clock, you can use the clock dividers to  generate the targeted 1MHz.

    Fig 3-1 on the UG gives a good overview on the CS block.

    Thanks

    Regards

    Kostas

  • Hi Kostas,

    Thanka a lot for the above link. In the data sheet I have seen we can use P1.2  for TA0CLK but when I configured P1.2 as input direction and set the clock source as TACLK it is not capturing the input can you see my configuration and let me know the errors.

    void timer_init()
    {
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
      CSCTL1 = DCOFSEL_6;                       // Set DCO to 8MHz
      CSCTL2 = SELA__LFXTCLK | SELS__HFXTCLK | SELM__DCOCLK;
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers to 1
      CSCTL4 |= LFXTDRIVE_3 | HFXTDRIVE_3;
      CSCTL4 &= ~(LFXTOFF | HFXTOFF);
      do
      {
        CSCTL5 &= ~(LFXTOFFG | HFXTOFFG);       // Clear XT1 and XT2 fault flag
        SFRIFG1 &= ~OFIFG;
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
      CSCTL0_H = 0;
    }

    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT

    // Configure GPIO
      P1OUT = 0;
      P1DIR = BIT0;                             // For LED
     
      P1DIR &= ~BIT2;                     // P1.2 input direction
      P1SEL0 |= BIT2;
      P1SEL1 &= ~BIT2;

      P2DIR |= BIT0;
      P2SEL0 |= BIT0;                           // Output ACLK
      P2SEL1 |= BIT0;

      P3DIR |= BIT4;
      P3SEL0 |= BIT4;                           // Output SMCLK
      P3SEL1 |= BIT4;

      PJSEL0 |= BIT4 | BIT5 | BIT6 | BIT7;      // For XT1 and XT2

      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;

      timer_init();

     TA0CCTL2 = CM_1 | CCIS_1 | SCS | CAP | CCIE;
                                                // Capture rising edge,
                                                // Use CCI2B=ACLK,
                                                // Synchronous capture,
                                                // Enable capture mode,
                                                // Enable capture interrupt

      TA0CTL = TASSEL__TACLK;  // Use TACLK as clock source,
                                                // Start timer in continuous mode
     
      __bis_SR_register(LPM0_bits | GIE);       // Enter LPM3 w/ interrupt
    //  while(1)
    //    __no_operation();
    }

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = TIMER0_A1_VECTOR
    __interrupt void Timer0_A1_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER0_A1_VECTOR))) Timer0_A1_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch (__even_in_range(TA0IV, TA0IV_TAIFG)) {
        case TA0IV_TA0CCR1:
          break;
        case TA0IV_TA0CCR2:
          timerAcaptureValues[timerAcapturePointer++] = TA0CCR2;
          //count1++;
          break;
        case TA0IV_TA0IFG:
          break;
        default:
          break;
      }
    }

    Can you say why I'm not getting timer interrupt when rising edge is coming?

  •  > Are you using the Launchpad? As delivered, the high frequency crystal (Y1) is not populated. Is it possible your program is stuck waiting (forever) for the HFXT to start up?

    Specifically: If you pause in the debugger, where is your program executing?

    [Edit: I forgot to mention: You're not setting the TA0CTL MC field, so the timer isn't counting. You should still get captures (since they're driven by ACLK), but they'll all be =0.]

  • Hi Bruce,

    As you have mentioned here if you pause in the debugger, where is your program executing? my program is executing but what happens as it is in low power mode my program is executing only this statement

    __bis_SR_register(LPM0_bits | GIE);

    Yea, thanks for the suggestions as you have mentioned to set the TA0CTL MC feild so, I'll set that feild and let you know whether I'm able to capture or not.

    EDIT:[ ypu have mentioned this You should still get captures (since they're driven by ACLK), but they'll all be =0. can you explain why should I'll get 0 if it is driven by ACLK]

    EDIT 2: [ TA0CTL = TASSEL__TACLK; so which mode I need to select I'm bit confused ]

  • Hi, can anyopne please suggest me any suggestions?

  • Hi Manish,

    just let's try to clear the thread, can you please tell us what is exactly what you would like to do and what are the questions, this would help to understand the code above.

    I know that we had some info from a former thread, but let's summarize the requirements here too.

    Please give us:

    - A short description of the project concept and maybe the Pins you plan to use.

    - also the response to the question above about the HW you are using.

    We are always here to support you.

    Waiting for your response

    Thanks

    Kostas

  • Hi Kostas,

    Purpose of the code is I'm using two timer one timer is using for a count for 500ms and second timer is for capture the input unknown frequency from the port 1.2. but we want to capture the difference between two count and find out the external frequency. As you know about from earlier thread but we are unable to get the accurate frequency. the same concept as previous code but this time second timer should use clock as timer clock. So this is the actual scnerio.

  • MC__CONTINUOUS is probably a reasonable choice.

    --------------------

    > P1SEL0 |= BIT2;
    > P1SEL1 &= ~BIT2;

    Per data sheet (SLAS704G) Table 6-49, this doesn't select TA0CLK. Try:

    > P1SEL0 &= ~BIT2;  // P1.2 as TA0CLK per SLAS704G Table 6-49
    > P1SEL1 |= BIT2;

    --------------------

    Neither of these would prevent capture from ACLK (CCIS=1). How do you know you're not getting a capture? Are you setting a breakpoint in the ISR? Or looking at the capture array?

    --------------------

    As Kostas keeps asking: What platform are you using?

  • > TA0CCTL2 = CM_1 | CCIS_1 | SCS | CAP | CCIE;

    Remove SCS here. If the timer is not actively counting, it has no edge to synchronize (ACLK) to, so it won't capture. A corollary is that if you ever try to measure a frequency below 32kHz, you'll lose captures and will compute incorrect results.  I.e. try:

    > TA0CCTL2 = CM_1 | CCIS_1 | CAP | CCIE;

  • Hi Kostas and Bruce,

    I'm using Launchpad, rally sorry about that I forgot to mention on my previous post. Thanks for the suggestion I'll try what you have stated in above post.

  • Hallo Manish,

    thanks for the info. I am using that board too.

    Unfortunately I can not test the board, as Bruce mentioned, the HF XT is not populated on the board (C4)

    I will try to update the board (it's not easy working from home)

    Regards

    Kostas

  • Hi Manish,

    I am working on a solution.

    Can you please replace your TA0CTL lone by following:

      TA0CTL = TASSEL__TACLK | MC__CONTINUOUS | TAIE ;

    In a test, I have left out the HFTX and only use the LFTX for ACLK. I set the SMCLK to DCO.

    By changing the TA0CLK (P1.2) frequency I can jump into the ISR and detect the expected counts.

    I will come back if I have more info

    Regards

    Kostas

  • Hi Kostas,

    Exteremely thanks for your effort will work on what you have stated in the above post.

    Thanks

  • Hi Manish,

    it has been a while since our last communication.

    Any update on the status? could you solve the issue.

    Thanks

    regards

    Kostas

  • Hi Kostas,

    I appologize for the delayed response, it was resolved. Thanks a lot for your support.

**Attention** This is a public forum