Jump to content

Setting external xtal on XT2 with msp430f149

Recommended Posts

I'm looking for help in setting up the clocks on a msp430f149. I can find all kinds of ways online after days of googling on how to setup clocks on most of the other devices (I also have an V1.4 launchpad) but no examples on how to setup up a msp430f149 that has a crystal on XT2. (happens to be 6MHz) I've inherited this project and it is what it is. I can get the chip to do what I need it to do in most ways (set and read ports etc.) but I can not get it to use the external crystal. If someone could give me the code that does just that I will buy you a beer next time we meet. Also I believe there is a way to directly output the clock to an output pin if I could be shown that as a bonus I would very much appreciate it.


My end goal is a serial port that does tx and rx. I've seen wonderful examples at http://dbindner.freeshell.org/msp430/ but I can't get any of the send and receive ones to work. I can get tx ones to work by playing with the clock settings but only using the internal RC clock.


I am Using CCS and C.


Thanks very much for reading this.




Link to post
Share on other sites

The file fet140_hfxt2.c in the example code package (SLAC015) shows how it's done:

  BCSCTL1 &= ~XT2OFF;                       // XT2= HF XTAL

  IFG1 &= ~OFIFG;                           // Clear OSCFault flag
  for (i = 0xFF; i > 0; i--);               // Time for flag to set
  while ((IFG1 & OFIFG));                   // OSCFault flag still set?

  BCSCTL2 |= SELM_2;                        // MCLK= XT2 (safe)
Link to post
Share on other sites



I'm located in Waterloo Ontario next time you are here you get the beer of your choice! It's working lol. Thank you so much.


Do you happen to know a way to get the clock out to a pin? Bonus pizza?





Check the datasheet and in particular port config / schematic matrix, usually there's a designated pin that can do SMCLKOUT or ACLKOUT or similar.  Not sure about the older F1xx parts.

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...