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.

MSP430F413: Msp430F413 every time the frequency is sometimes different

Part Number: MSP430F413

hi,Msp430F413 work with 32KHZ, use the watchdog timer time work, program debugging found, each time the frequency is sometimes different, there are two cases, 10 times there are 2 times, the frequency is about 2/1. Don't know what's the reason? Is it wrong to set up 32KHZ, or is it any other reason? Part of the program see the following, thank you!

PS: The program is modified under the fet410_wdt_02 sample of MSP430x41x.

The program is modified under the fet410_wdt_02 sample of MSP430x41x.

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; //
FLL_CTL0 |= XCAP18PF; // Set load cap for 32k xtal
DelayMS(1000);//100MS
P2OUT = 0xff; // led1-led8 
P2DIR = 0xff; //
P6OUT = 0xff; // led9-led16 
P6DIR = 0xff; //
P5OUT = 0x20; /
//,,,,, Other IO port initialization
Play(90);
WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer
IE1 |= WDTIE; // Enable WDT interrupt
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/interrupt

}

// Watchdog Timer interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void)
#else
#error Compiler not supported!
#endif
{
unsigned int j;
FLL_CTL0 |= XCAP18PF; // Set load cap for 32k xtal
DelayUS(50);
JS++;
if(JS==120) //
{
P1OUT&=~0x20; //
}
if(JS==121)
{
P1OUT|=0x20; //
JS=0;
}
JS=0;//
P5OUT&=~0x01; //
WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer

}//P3,P4
}

  • Hi,

    could you please specify which clock frequency seems to be different? How did you perceive this, during debug or do you have extra code to measure time intervals for example by using a Timer to capture the time interval?

    I'd suggest you to have a look at the Software Coding Techniques for MSP430 MCUs Application Report to get some guidance on the suggested code flow on MSP430 MCUs.

    I noted that you're conducting some register settings inside the interrupt service routine and I'd suggest for you ta start looking into this to see if you could restructure your code -  you'll find guidance for that in the Application Report. Please also take a look at your WDTCTL settings. Currently, your interrupt service routine shows your repeating the register settings. As far as I see your not changing the seetings done in main, so those are not needed and might only generate overhead.

    Please let me know if any of this helped you and please let me know how you tested and verified the different frequencies.

    Best regards,

    Britta

  • > FLL_CTL0 |= XCAP18PF; // Set load cap for 32k xtal

    My first guess is that your crystal is having trouble starting. Did you try different XCAP values?
  • I changed the equivalent crystal oscillator, and it's the same phenomenon

  • hi,

    a buzzer signal program output( BeePDeed (); ), the voice is not the same, oscilloscope detection frequency output is not the same.

    my program is modified under the fet410_wdt_02 sample of MSP430x41x, fet410_wdt_02 sample to See the following. my program framework is the same as this sample。Fet410_wdt_02 sample, Can I modify the application directly?

             My program framework Description: using WDT configured for Interval Timer mode, Every 250ms detect of IO port  based on 32kHz ACLK WDT clock source.      ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz..

    Next week, we need to deliver product samples to customers, do not know how to deal with it, and help modify the procedural framework.

      thank you!

    PS:1、 fet410_wdt_02 sample  Demo - WDT, See the following , 

          2、 My program framework sees the first PS program code。

    //******************************************************************************
    // MSP-FET430P410 Demo - WDT, Toggle P5.1, Interval Overflow ISR, 32kHz ACLK
    //
    // Description: Toggle P5.1 using WDT configured for Interval Timer mode.
    // Interrupt toggles LED every 250ms based on 32kHz ACLK WDT clock source.
    // ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
    // //* An external watch crystal between XIN & XOUT is required for ACLK *//
    //
    // MSP430F413
    // -----------------
    // /|\| XIN|-
    // | | | 32kHz
    // --|RST XOUT|-
    // | |
    // | P5.1|-->LED
    //
    // M. Buccini
    // Texas Instruments Inc.
    // Feb 2005
    // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
    //*****************************************************************************
    #include <msp430.h>

    int main(void)
    {
    WDTCTL = WDT_ADLY_250; // WDT 250ms, ACLK, interval timer
    FLL_CTL0 |= XCAP14PF; // Configure load caps
    IE1 |= WDTIE; // Enable WDT interrupt
    P5DIR |= 0x02; // Set P5.1 to output direction

    __bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/interrupt
    }

    // Watchdog Timer interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=WDT_VECTOR
    __interrupt void watchdog_timer(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(WDT_VECTOR))) watchdog_timer (void)
    #else
    #error Compiler not supported!
    #endif
    {
    P5OUT ^= 0x02; // Toggle P5.1 using exclusive-OR
    }

  • Hi,

    did you try running the example code without making any changes first? If so, were you able to verify that your Crystal is working fine and starting? Did you see the same frequency issue already before making any adjustments?

    You can of course take an example code and then make adjustments to it as necessary for the application.

    For some guidance on the Crystal Oscillator please have a look at the MSP430 32kHz Crystal Oscillators Application Report.

    Let me know if this helps.

    Best regards,

    Britta

  • Hi,

    as I didn't hear back from you I assume that you've been able to solve your issue.
    I'll go ahead and close this thread shortly. You'll be able to re-open it if needed by simply replying to my post.

    Please mark the asnwer which helped you to move on with your application so that others can follow the same guidance.

    Best regards,
    Britta

**Attention** This is a public forum