3
\$\begingroup\$

I'm want to use an external low frequency crystal (32kHz) for the timer in my MSP430G2553 and the internal oscillator at 8MHz, but in the datasheet I can't see how I should use the external crystal for the timer. As there only appears to be one pin(TACLK). So how would the design for the oscillator look?

\$\endgroup\$
  • \$\begingroup\$ what frequency crystal are you thinking about? MSP430 generally wants to have a low-frequency (32768) crystal attached, then uses its internal oscillator for higher frequencies. \$\endgroup\$ – markrages Feb 3 '13 at 16:47
  • \$\begingroup\$ @markrages thats exactly what I want to do. But i'm unsure on how to do this. \$\endgroup\$ – Dean Feb 3 '13 at 18:00
9
\$\begingroup\$

To use an external 32.768 KHz crystal with the MSP430G2553, the crystal needs to be soldered between the Xin and Xout pins of the microcontroller. In the DIP package, those are pins 18 and 19. No additional components are required for this.

TA0CLK has nothing to do with this crystal's connection, please see the pin descriptions in the datasheet.

See this schematic of the MSP430 Launchpad Target Microcontroller section:

MSP430 Launchpad Target Board

You can see the two 0 Ohm resistors on the pins 18 and 19 - the crystal attaches between them.

Please note:

  • Adding a crystal prevents those pins from being used as GPIO Pin 2.6 / TimerA TA0.1 (the Xin pin's other functions) and GPIO Pin 2.7 (the Xout pin's other function.
  • Instead of crystal, a digital clock from an oscillator can also be supplied to Xin in bypass mode.
  • For crystals of frequency higher than the 32.768 KHz crystal, appropriately sized load capacitors are required in addition. See the relevant part-specific datasheet for this.

UPDATE:

Once the 32.768 KHz watch crystal is connected to the MSP430, the following notes are handy to confirm that the crystal is operational, and of course to use the crystal going forward.

  • The crystal on XIN / XOUT is used as ACLK. Conversely, for using ACLK, a crystal must be connected between XIN and XOUT.
  • If the implementation is on an MSP430 Launchpad board, note that crystal diagnostic code is provided in Justin's Tech Blog - the gold standard that pretty much everyone followed in the early days of the Launchpad.
  • Other such walk-throughs are in NJC's Launchpad Blog, and in the TI "Getting Started with the MSP430 Launchpad" document, in the "Optional Lab Exercise – Crystal Oscillator" section.
  • The internal (on-chip) matching capacitance needs to be set for the crystal to work: Set BCSCTL3 (Basic Clock System Control 3), BCSCTL3 |= XCAP_3; for the 12.5 pF watch crystal provided with the Launchpad.
  • Detailed information on using Low Frequency Crystals is provided in this TI document.
  • An excellent, step by step explanation and verification code is provided in this blog.
  • Most important: Code using LF crystal ACLK does not function as expected while stepping through in debug mode, you have to run the code in "Run" mode for the various diagnostic code fragments mentioned above to work. This quirk is apparently not documented anywhere, I spent a fair bit of time removing and resoldering the crystal on my first launchpad, assuming a failure, till I figured this out.
\$\endgroup\$
  • \$\begingroup\$ Then what is the function of TA0CLK on PORT 1? \$\endgroup\$ – Dean Feb 3 '13 at 18:41
  • \$\begingroup\$ TA0CLK is "Timer0_A, clock signal TACLK input". An alternate reference for Timer 0, in case you want Timer 0 to use a different reference clock than the MSP430 system clock or main peripheral clock. \$\endgroup\$ – The Photon Feb 3 '13 at 18:47
  • 1
    \$\begingroup\$ In case it's not clear, Timer 0 is a peripheral that can count time between events on an input pin and generate an interrupt for various conditions; or generate a periodic interrupt at fixed intervals. It's not a clock source to drive the rest of the chip. \$\endgroup\$ – The Photon Feb 3 '13 at 19:07
3
\$\begingroup\$

Parts like microcontrollers are often too complex to fit all the data about them into just a datasheet. For your part there's also a MSP430x2xx Family User's Guide (Rev. I).

In that document on page 366, you'll find "The timer clock can be sourced from ACLK, SMCLK, or externally via TACLK or INCLK."

enter image description here

And, on page 278,

Three clock signals are available from the basic clock module+:
• ACLK: Auxiliary clock. ACLK is software selectable as LFXT1CLK or VLOCLK. 
  ACLK is divided by 1, 2, 4, or 8. 
  ACLK is software selectable for individual peripheral modules.
• MCLK: Master clock. ...
• SMCLK: Sub-main clock. SMCLK is software selectable as 
  LFXT1CLK, VLOCLK, XT2CLK (if available on-chip), or DCOCLK. 
  SMCLK is divided by 1, 2, 4, or 8. SMCLK is software selectable 
  for individual peripheral modules.

So you need to select either ACLK or SMCLK as the clock source for your timer, and then select the crystal source ("LFXT1CLK") as the source for your ACLK or SMCLK. The choice between ACLK and SMCLK probably comes down to which power-down modes you need to use, and whether you need to keep the timer active during power down.

Building an external oscillator to feed TACLK will likely use substantially more power than using the the uC's own crystal circuit.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.