Jump to content

External Oscillator in Energia

Recommended Posts


Has there ever been a method developed for Energia that allows it to use an external crystal? I'd like to have the ability to enable a low frequency crystal as well as a high frequency crystal on the msp430fr5994. Does anyone have any recommendations for implementing this? 



Link to post
Share on other sites

@StefanSch Thank you for your response. Do you know if there's a way to do this from inside of energia? As far as I can tell, the J pins are all disabled and it doesnt even have a way of configuring the LFXT. I can't imagine it's all that difficult to add a few lines of code to enable the HFXT but I don't even know where to start. Any pointers would be great, can i apply some of the examples that you posted into Energia? 



Link to post
Share on other sites

As mentioned

Engeria is already configured to start and LFXT - this of course means to enable the PORTJ pins for the XTAL functions.

So LFXT should start if you have connected an LFXT properly.

For HFXT you can go the the page (linked above)

and take this peace of code and put in into your Energia setup function:


   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;

    CSCTL0_H = CSKEY_H;                     // Unlock CS registers
        CSCTL5 &= ~(LFXTOFFG | HFXTOFFG);   // Clear XT1 and XT2 fault flag
        SFRIFG1 &= ~OFIFG;
    } while (SFRIFG1 & OFIFG);              // Test oscillator fault flag
    CSCTL0_H = 0;                           // Lock CS registers

It does set the PORTJ for the LFXT again but this does not hurt.

If you do not come out of this part of code then you have an issue with the Oscillator.

Esp. for the HFXT you need to check for the right load capacitors !!!

Then once they are running you can select which internal clocks should use it:




Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...