Jump to content
Sign in to follow this  
32xan

could not source MCLK form watch 32KHz crystal

Recommended Posts

I'm failing to see why I could not clock the CPU of the msp430g2452 for 32KHz wath crystal. I'm observing the same behavior from two different launchpad boards with soldered  32Khz crystal (one tiny yellow crystal that came with the kit and cylinder bigger one); and with several different msp430g2452. I'm observing the 32KHz square on P1.0 when it set to output the ACLK. 

Seems that the MCLK is always clocked from DCO regardless of the SELM_[0-3] I'm trying to push to  BCSCTL2. 

I'm checking P2.1 output as it is software toggled in endless loop; it is 20 times slower than MCLK.

What am I missing? in the block diagram slau144 page 275 MCLK should source  DCO when set SELM_0 or SELM_1; or clock from LFXT1 when set SELM_2 or SELM_3.

 

Code:

#include  <msp430g2452.h>

int main(void) {
  WDTCTL = WDTPW + WDTHOLD;

//   // ACLK 32KHZ SMCLK 1MHz MCLK 50Hz
//   P1DIR |= 0x11;                            
//   P1SEL |= 0x11;
//   P2DIR |= 0x01;    for (;;)     P2OUT ^= 0x01;   

  // ACLK 4KHZ SMCLK 130KHz MCLK 200Hz
  P1DIR |= 0x11;                            
  P1SEL |= 0x11;
    BCSCTL2 |= SELM_2;  // SELM_0 or SELM_1 or SELM_2 or SELM_3 has no effect on P2.0 output
  BCSCTL1 |= DIVA_3;
  BCSCTL2 |= DIVM_3;
  BCSCTL2 |= DIVS_3;
  P2DIR |= 0x01;    for (;;)     P2OUT ^= 0x01;   
}

 

 

Share this post


Link to post
Share on other sites

Glad to see you worked it out.

 

For most standard/common setups, I keep a collection of code snippets, so I don't need to think too hard.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×