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.

msp430g2553 external clock

Other Parts Discussed in Thread: MSP430G2553

The code that is below is from the ti code sample for msp430g2553.

It says in the comment that external watch crystal installed on Xin and Xout is required for ACLK.

What I am trying to ask is does this program use an external clock or not? 

The code shows an O/P on P1.0/ACLK. But where are the PSEL for Xin and Xout?

If this is not the code for the external clock, what is? The readme text file has no description of the .c files.

//******************************************************************************

//  MSP430G2xx3 Demo - Basic Clock, Output Buffered clocks with preloaded DCO

//                     calibration constants for BCSCTL1 and DCOCTL.

//  

//  Description: Buffer ACLK on P2.0, default SMCLK(DCO) on P1.4 and MCLK/10 on

//  P1.1. DCO is software selectable to 1, 8, 12, or 16Mhz using calibration

//  contstants in INFOA.

//

//  ACLK = LFXT1 = 32768, MCLK = SMCLK = Selectable at 1, 8, 12 or 16Mhz

//  //* External watch crystal installed on XIN XOUT is required for ACLK *//

//

//               MSP430G2xx3

//             -----------------

//         /|\|              XIN|-

//          | |                 | 32kHz

//          --|RST          XOUT|-

//            |                 |

//            |       P1.4/SMCLK|-->SMCLK = Default DCO

//            |             P1.1|-->MCLK/10 = DCO/10

//            |        P1.0/ACLK|-->ACLK = 32kHz

// 

//  D. Dang

//  Texas Instruments Inc.

//  December 2010

//   Built with IAR Embedded Workbench Version: 3.42A

//******************************************************************************

 

#include  <msp430g2553.h>

 

void main(void)

{

  WDTCTL = WDTPW +WDTHOLD;                  // Stop Watchdog Timer

  if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                     

  {  

    while(1);                               // If calibration constants erased

                                            // do not load, trap CPU!!

  } 

 //1Mhz

  BCSCTL1 = CALBC1_1MHZ;                    // Set range

  DCOCTL = CALDCO_1MHZ;                     // Set DCO step + modulation */

 

/* //8Mhz

  BCSCTL1 = CALBC1_8MHZ;                    // Set range

  DCOCTL = CALDCO_8MHZ;                     // Set DCO step + modulation */

 

/* //12Mhz

  BCSCTL1 = CALBC1_12MHZ;                   // Set range

  DCOCTL = CALDCO_12MHZ;                    // Set DCO step + modulation*/

 

/* //16Mhz

  BCSCTL1 = CALBC1_16MHZ;                   // Set range

  DCOCTL = CALDCO_16MHZ;                    // Set DCO step + modulation*/

 

  P1DIR |= 0x13;                            // P1.0,1 and P1.4 outputs

  P1SEL |= 0x11;                            // P1.0,4 ACLK, SMCLK output

 

  while(1)

  {

    P1OUT |= 0x02;                        // P1.1 = 1

    P1OUT &= ~0x02;                         // P1.1 = 0

  }

}

 

  • Hi,

    The Xin and Xout are on P2.6 and P2.7.  The default state of the P2SEL is 0xC0 which has these pins selected for crystal operation.  So no need to set P2SEL it is already in the correct state after a reset.

    HTH,

    Barry

  • Hi Barry,

    thanks for pointing that out. The comment for the example is indeed a bit unclear and assumes the default conditions of the XT1 hence requiring no additional code to have it up and running.

    Hi Dominic,

    I'll add into the comments to make it a bit more clear for the next code example update.

    Regards,

    Dung

  • Thanks Barry and Dung:

     

    So, if my clock is configured as shown in the sample code... I should be able to use LPM3 for a timer based interrupt(wake up and sleep on some predetermined time interval) with TA0 configured using SMCLK as clock select, correct?

  • Hi Dominic,

    In LPM3 the SMCLK is turned off. ACLK is the only clock that is on in LPM3. You would need to set timer A to be source from ACLK.

    Barry

  • Dominic,

    what is the interval/ wake-up frequency that you're looking for? If it is less than 32kHz (preferrably much less, a fraction of 32768) then you can use the XT1 --> ACLK as the clock source for your Timer interrupt.

    If this frequency is much higher, you will need a higher speed clock source, such as DCO --> SMCLK. If this is the case, the device needs to stay in LPM0 in order for the SMCLK to run.

    In the same code example set, please take a look at some of the timer code examples, hopefully that would give you a better idea on which clock, timer & interval modes to use.

     

    ~Dung

**Attention** This is a public forum