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.

External clock initialization problem on MSP430

Other Parts Discussed in Thread: MSP430F5438A-EP

Problem of MSP430 on R&D project for product under industrialization process startup. The product I am working on is composed of a MSP430F5438A-EP and 1 external oscillator of 32.768Khz and 1 quartz 32MHz connected respectively to XIN and XT2IN and XT2OUT. We have 20 prototypes of this product and we noticed a bug that occurs randomly. In the code we are using TI software library to manage peripherals and initialize clocks etc. After investigating it seems that the CPU blocks after executing 2 functions (from ucs.c source file described in the snippet below). The library version used was updated in 2014. Do you have any idea why the MCU crashes at this step randomly. Is there an option on MSP430F5x to specify that we use an oscillator for XT1 and not a quartz (as it is on MSP430F2XX family). The toolchain to compile the code is IAR Embedded Workbench v5.40.1.50328. Thanks for your kind help.

Best regards. Mickael

UCS_turnOnLFXT1(UCS_XT1_DRIVE_2, UCS_XCAP_0)
UCS_initClockSignal(UCS_MCLK, UCS_XCAP_0UCS_XT2CLK_SELECT, 1)
  • The function UCS_turnOnLFXT1() turns on the XT1 crystal oscillator circuit.

    But this is not what you want; you want to bypass it. Use UCS_bypassXT1().

  • Hi Clemens,

    Thanks for your reply. I tested using UCS_bypassXT1() but it seems that the problem has been shifted to the initialization of the second clock High Frequency. As I told you I am using 2 external clocks (1 LF oscillator and 1 HF quartz 32MHz).

    Here is my code for the initialization. It seems now (only in release mode and not in debug) that the MCU blocks at the execution of this function:

    void Main_ClockInit(void)

    {

        __disable_interrupt();
        
        //LF clock initialization
        UCS_clearFaultFlag(UCS_DCOFFG|UCS_XT1LFOFFG|UCS_XT2OFFG);
       
        //Init xt1
        UCS_bypassXT1(UCS_XT1_LOW_FREQUENCY);
    //    UCS_turnOnLFXT1(EXT_LF_CRYSTAL_DRIVE, EXT_LF_CRYSTAL_CAP);
       
        UCS_setExternalClockSource(L32768, 32000000);
        
        //Init ACLK on xt1
        UCS_initClockSignal(UCS_ACLK, UCS_XT1CLK_SELECT, UCS_CLOCK_DIVIDER_1);
        
        //HF clock initialization  
        UCS_turnOnXT2WithTimeout(UCS_XT2_DRIVE_24MHZ_32MHZ, 65000);


        SFR_disableInterrupt(SFR_OSCILLATOR_FAULT_INTERRUPT);
        
        __no_operation();__no_operation();__no_operation();

    UCS_initClockSignal(UCS_MCLK, UCS_XT2CLK_SELECT,1);

    /* MCU is blocked in the function above */

    __no_operation();__no_operation();__no_operation();

    UCS_initClockSignal(UCS_SMCLK, UCS_XT2CLK_SELECT, 1);

    __no_operation();__no_operation();__no_operation();

    }

    Could you tell me what is wrong in this code. Why the MCU freezes when init MCLK.


    Thanks in advance for your kind help.

    Best regards

    Mickael

  • Does UCS_turnOnXT2WithTimeout() succeed? It does not make sense to call a *WithTimeout function without checking the error code.

    Please note that UCS_CLOCK_DIVIDER_1 does not have the value 1.

    The function UCS_initClockSignal() does not contain any loop. Where exactly does it block?
  • Hi,
    Previously, I used the UCS_turnOnXT2 function but it didn't work, so I thought it was better to use the one with timeout in order to let the quartz stabilize maybe. Concerning the error code that I don't read is that I don't need it, because if it doesn't work there is nothing to do, the product cannot be used.

    I imagine that this constant doesn't have the value 1, that's I am calling the function with this constant and not 1.

    Actually, how did I test it, classically I toggled a LED before calling the function, and toggled back the LED at the return of the function. But is doesn't appear here in the code I sent.

    Is there any steps missing to complete the clocks initialization?

    Regards.
    Mickael

**Attention** This is a public forum