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 oscillator

Other Parts Discussed in Thread: MSP430G2744

Hy, this is my first project with a MSP430G2744 mikrocontroller.

unsigned int i;

    /*
     *- XT2OFF needed to be enabled
     *- XTS needed to be enabled (high frequency mode)
     */
    BCSCTL1 =  XTS + XT2OFF;
    
    /*
     * Set external 3- to 16-MHz clock source
     */
    BCSCTL3 = LFXT1S_2 ;

    /*
     * Wait until oscillator settle
     *
     * Clear Oscillator Fault Flag
     * wait 60us
     * Check Oscillator Fault Interrupt Flag
    */
     do {
        IFG1 &= ~OFIFG;
        for (i=0; i < Mcu_wait; i++)
            {
            /* do nothing */
            }
        } while(IFG1 & OFIFG != 0);

    /*
     * Enable Oscillator fault Interrupt
     */
         IE1 |= OFIE;

     /*
      * Select LFXT1CLK as MCLK
      * Select LFXT1CLK as SMCLK .
      * Set the divider of the SMCLK to 2 because the generated frequency for SMCLK should be 8MHz
      */
      BCSCTL2 = SELM_2 + SELS + DIVS_1;

I connected a 16Mhz oscillator to my MSP XIN and XOUT.

The goal of the project is to operate the MCLOCK with 16Mhz and the SMCLOCK with 8Mhz.

I tried to toggle a Pin at my MSP430g2744 to verify the CPU speed but it is to slow only 10Khz..

Can somebody help me to solve this problem?

  • Take a look at this thread:

    http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/261233.aspx

    I am going thru this exercise myself now :-) 

    Quick look at the datasheet shows a difference though. The G2744 you use officially supports the HF mode on XT1 and HF external clock at XIN, whereas the G2553 I use does not. The thread above is basically an out of spec experiment.

  • Alexander Ehni said:
    I tried to toggle a Pin at my MSP430g2744 to verify the CPU speed but it is to slow only 10Khz..

    Depends on how you toggle the pin.  A pin toggle isn't done on one clock cycle.
    However, I'd expect a bit more than 10kHz if the CPU runs on 16MHz. What is your toggle code?

    You can get a direct output of SMCLK on P2.1 or P1.4
    Set P1SEL.4 and P1DIR.4 or P2SEL.1 and P2DIR.1

    Alexander Ehni said:
        BCSCTL3 = LFXT1S_2 ;

    External clock source is LFXT1S_3. _2 is for 16Mhz crystal, not external oscillator.

    Alexander Ehni said:
            for (i=0; i < Mcu_wait; i++)
                {
                /* do nothing */
                }

    Since the code does nothing, the compiler may discard it completely. Use __delay_cycles() instead of 'cheap' for-loops.

  • Hy Jens

    why did you delet your code?

    Is it possible to connect a extern crystal oscillator of 16Mhz?

  • It appears that MSP430G2x44 has a better XT1 HW than the rest of the G2 family. External 16MHz clock is allowed, see pg34 of the manual.

  • Is it possible to connect a 16Mhz "analogue" crystal instead of a digital one.

    If I need a digital one which one is the best to use for 16 Mhz?

    Is it right that I can use a analogue cristal up to 8Mhz? (page 34)

    regards

  • Apparently yes. Where do you see the 8MHz limit ? Pg34 shows 2-16MHz for HF mode 2 and 3-3.6V Vcc.

    If you have not done so already I suggest downloading the family manual (slau144j.pdf). It has a detailed description for the XT1 clock internal hardware.

  • I found this value at page 35 in Figure 17 msp430g2744_Datasheet.pdf.

    The Graph is stopping at 8Mhz in LFXT1Sx=2 Mode.

    regards.

  • I see. What I really find confusing about the Fig17 is that the graph also shows LFXT1Sx=3 mode. This is an *external* oscillator mode and there should be no crystal allowance constraint at all. I think Fig18 is just the internal clock tree or buffer power consumption in mode 3.

    Based on the pg34 specs I'd try the 16MHz crystal. Whether it is suitable for production is a question for official TI technical support IMHO. It is not perfectly clear from the datasheet.

  • Hi,

    You are correct. 16Mhz crystals are supported with LFXT1Sx = 2 as shown in the table in page 34.

    The same table shows a typical OA using a 16Mhz crystal. 

    Fig17 and Fig18 seem to be incorrect and I'll try to find the cause of this problem and fix it.

    Regards,

    Luis R

  • This is my whole Toggle code:

    #include <msp430.h>

    /*
     * main.c
     */
    #define INTERRUPT __interrupt
    #define Mcu_wait (50u)
    void Mcu_Init(void)
    {
        unsigned int i;

        /*
         *- XT2OFF needed to be enabled
         *- XTS needed to be enabled (high frequency mode)
         */
        BCSCTL1 =  XTS + XT2OFF;
     

        /*
         * Set external 3- to 16-MHz oscillator source
         */
        BCSCTL3 = LFXT1S_2 ;

        /*
         * Wait until oscillator settle
         *
         * Clear Oscillator Fault Flag
         * wait 60us
         * Check Oscillator Fault Interrupt Flag
        */
         do {
            IFG1 &= ~OFIFG;
            for (i=0; i < Mcu_wait; i++)
                {
                 __delay_cycles(20);
                }
            } while(IFG1 & OFIFG != 0);

           /*
          * Select LFXT1CLK as MCLK
          * Select LFXT1CLK as SMCLK .
          * Set the divider of the SMCLK to 2 because the generated frequency for SMCLK should be 8MHz
          */


          BCSCTL2 = SELM_2 + SELS + DIVS_1;


    }



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

        /*Only to see SMClock this is now dissabled*/

        //P1SEL |= (unsigned char)BIT4;

        /*set as output */  

        P1DIR |= (unsigned char)BIT4;


        Mcu_Init();
        while(1)
        {
        P1OUT = ~P1OUT;
        }
        return 0;
    }

    When I start this code I can see a rectangular signal on my oscilloscope with the frequency of 10Khz.

    After this test I commented out the function call Mcu_Init(), and now I can see a rectangular signal on my oscilloscope with the frequency of 96Khz.

    By changing the frequency to LFXT1 (16Mhz) the freqency is sinking instead of rise up.

    Is there a code failure or I have a flaw?



  • Alexander Ehni said:
    why did you delete your code?

    Because I didn't notice at first that the G2744 does allow high-frequency crystals (all other G2 devices don't). So it was a wrong answer.

    Alexander Ehni said:
    Is it possible to connect a extern crystal oscillator of 16Mhz?

    It is possible to add an external oscillator (independent of its type - oscillators provide a digital frequency signal) as well as a plain crystal.

    Luis RC said:
    Fig17 and Fig18 seem to be incorrect and I'll try to find the cause of this problem and fix it.

    I agree (Fig. 16 too). I added it to my list of documentation bugs, but I didn't get any feedback on my last submission yet, so I planned to collect a few more before submitting the next bunch.
    The whole list is 26k, and I already removed those which I noticed to be already fixed in newer revisions of the datasheets and users guides.

    Alexander Ehni said:
        BCSCTL1 =  XTS + XT2OFF;

    This line resets RSELx from the default RSEL_7 to RSEL_0. This causes the DCO to go from ~1MHz down to <100kHz.
    If the crystal fails, MCLK will fallback to DCO.

    And your waiting loop to clear the fault flags and switch to the crystal has a problem:

    Alexander Ehni said:
            } while(IFG1 & OFIFG != 0);

    the != operator has higher precedence than the bitwise AND.
    So it actually reads
    while (IFG1 & (OFIFG !=0));

    As soon as any bit in IFG1 8except for OFIFG, which you clear) is ever set, this loop will loop eternally. Well, a !=0 check is never required. If the result is != 0, it is considered true already while a zero result is considered false.

    I guess what happens is that the crystal fails after it was initially passing the startup loop. So MCLK falls back to DCO, which is running on ~100kHz now.

  • many thanks that helps me a lot

  • I forgot to mention that a plain high-speed crystal also requires the proper load capacitors. The internal selectable caps are only for low-frequency use and should be disabled.

**Attention** This is a public forum