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: TIMER_A works sporadically with ACLK

Part Number: MSP430G2553

Hello,

I have been trying to blink an LED with TIMER_A using the ACLK 32kHz internal crystal on the MSP430G2553 using the MSP-EXPG2 development board.  I am powering the MCU using the USB connection with the computer.  I have seen a variety of issues including; perfect performance (including accurate timing) in stand-alone mode, twice as fast blinking in debug mode, no operation in stand-alone mode, frequency of flash varies with hand proximity to board (as hand gets closer to board LED flashes more quickly), and no operation in stand-alone mode while working fine in debug mode (when board is off grounding mat). 

I originally did not "tie-up" unused pins and though that was the issue.  So I tied up all unused pins.

It seems like it is a grounding issue.  The board has worked in stand-alone mode if sitting on a grounding mat that is grounded to house ground.  Though it will not work when an external LED is set-up on a solderless breadboard.  In this situation the board is off the mat because the jumper cables I am using are male-male and are plugged into the bottom of the headers. 

The only time I do not have these issues is when I use the SMCLK clock.  It works in debug and stand-alone with the same timing on or off the grounding mat, with hands close or far away from the board.

The code bellow is what I used when using SMCLK.  When trying to use ACLK I make these two changes...CCRO=1023 and TASSEL_1.  I originally was using TIMER_A with an interrupt but changed it to hardware driving the LED output, and have similar issues.

Any ideas why I am seeing these issues with ACLK and not with SMCLK.  Also note I have had this issue with two different MSP-ESP420G2 development boards.  Thanks for any advice you can provide.
Also note I want to use the ACLK crystal because it is more accurate over the operating temperatures of the MSU as compared to the RC type clocks of SMCLK and VLO.

#include <msp430.h>

int main(void)

{

   WDTCTL = WDTPW + WDTHOLD;

   //Setup Timer A and Channel 0 to toggle mode. 

   CCR0 = 65535

   TACCTL0 = OUTMOD_4;

   TACTL = TASSEL_2|ID_3|MC_1|TACLR;

   //Set P1.5 as output for TA0.0

   P1SEL |= BIT5;

   P1DIR |= BIT5;

   //Set all unused pins as output and set high with pull up resistor.

   P1OUT |= BIT0|BIT1|BIT2|BIT3|BIT4|BIT6|BIT7;

   P1REN |= BIT0|BIT1|BIT2|BIT3|BIT4|BIT6|BIT7;

 

   P2REN |=BIT0 | BIT1|BIT2|BIT3|BIT4|BIT5;

   P2OUT |= BIT0 |BIT1|BIT2|BIT3|BIT4|BIT5;

 

while(1) {}

// infinite loop

}

  • This really sounds like a flaky crystal connection. Is the crystal matched properly with the XCAP setting (6pF if you don't change it)?

    The erratic behavior indicates that LFXT1 is failing over to the VLO, then going back to the crystal when LFXT1 starts up again. The holding-your-hand-near-it experiment is also a clue here.

    Even though you've seen this on two different boards, it still might be worth touching a soldering iron to the crystal connection to reflow the solder (worked for me!).
  • Hello Bruce,
    Thank you for your response. I am very new to this, so I did not realize that the crystal was actually outside of the MCU chip. I see there is a small 3 mm square section of solder beside the XIN and XOUT pins. I updated the BCSCTL3 = XCAP_1; to match the capacitor to 6pF like you suggested. This did not fix the problem. But you are right about my hand to the board effect. Right now how I have it set up it won't work at all in stand alone mode, but if I bring my finger very close to the 3 mm square then the LED flashes.

    I tried your soldering iron suggestion. I melted the solder and re-tried in stand-alone. It worked, however, if I brought my finger close to the square (about 25 mm) then the LED still flashed quicker. So I decided to remelt the solder again, now it is like before. Without my finger close to the crystal the LED does not flash.

    How frustrating. I guess I will try and keep re-soldering the crystal until I get it right.

    Thanks again for your response. I will let you know when I get it working properly.

    Kevin
  • Hello Bruce,

    Thank you for your response. I tried both of your suggestions. The first, setting BCSCTL3 = XCAP_1; did not fix the issue.
    I tried re-soldering the crystal (the 3 mm square beside the XIN and XOUT pins) a number of times. After the first re-solder the LED flashed on its own in stand-alone but when I moved my had close to the board the LED flashing frequency increased. So attempted another couple of re-solders. Now it is back to before, where the LED didn't flash unless I bring my finger to about 12 mm from the crystal.

    Any other suggestions? Very odd that this happens.

    Thanks.
  • When you populate crystal, you must desolder R28 and R29 too. Also after you done soldering job - properly clean PCB, make sure there is no flux residue on the board. Any leakage around XTAL pins could cause erratic operation of the oscillator.
  • Hello Ilmars,
    I was confused about this 32 kHz Crystal. Reading the MSP430G223 Data Sheet it says on page 1 that the " Basic Clock Module Config includes: Internal up to 16 MHz, Internal low power low freq Oscillator, 32 kHz Crystal, External Digital Clock Source." Then on p 14 of the data sheet "Auxiliary clock (ACLK), sourced either from a 32768-Hz watch crystal or the internal LF oscillator."

    From this it gives the impression that the 32 kHz crystal is within the MCU, but on second look it does not indicate either way, if it is internal or external.

    Reading the MSP430X2XX User's Guide in the Basic Clock Module chapter on page 273 you find the following:

    p273"LFXT1CLK: Low-frequency/high-frequency oscillator that can be used with low-frequency watch
    crystals or external clock sources of 32768 Hz or with standard crystals, resonators, or external clock
    sources in the 400-kHz to 16-MHz range."

    p276"The basic clock module+ addresses the above conflicting requirements by allowing the user to select from
    the three available clock signals: ACLK, MCLK, and SMCLK. For optimal low-power performance, ACLK
    can be sourced from a low-power 32768-Hz watch crystal (if available), providing a stable time base for
    the system and low-power standby operation, or from the internal low-frequency oscillator when crystal accurate
    time keeping is not required."

    So this indicates that the 32 kHz crystal is indeed an external clock source and only the VLO (12 kHz) is internal. But I have to admit the language is still a bit vague.

    I have now found the little crystal package in the kit.

    I found the reference to desoldering R28 and R29 that you talk about. It is on pg 12 of the MSPEXP-430G2 User Guide.

    "The oscillator signals are connected to J2 to use the signals on an attached application board. In case of
    signal distortion of the oscillator signals that leads to a fault indication at the basic clock module, resistors
    R29 and R28 can be used to disconnect the pin header J2 from the oscillating lines."

    Ok, I will try and install this crystal on the provided pad within the oval on the MSP-EXP430G2 and let you know how it works. I will see if it works with R29 and R28 connected and if I still get a fault as shown in register LFXT1OF (MSP430X2XX user guide p 285) then I will desolder them as well. But from the above it seem like you only need to do this if connecting an external clock to the J2 pins while using an application board.

    Here is a link to a person's blog about installing the 32 Khz crystal.

    www.msp430launchpad.com/.../using-aclk-and-32khz-crystal.html

    For completeness my crystal packaging indicates a 12.5pF (XCAP_3 ) (MSP430X2XX user guide p 285), compared to Bruce's 6 pF (see MSP430X2XX pg 275 as well). I've included all the references here for anyone else that has had similar confusion over this issue.

    Thanks for the help.
  • I tried soldering the crystal in place with no success. Abandoning. Will develop using SMCLK. Thanks for two responses.
  • Kevin Peffers said:
    I tried soldering the crystal in place with no success

    Did you clean PCB using isopropyl alcohol? - This is very important because crystal oscillator is very sensitive circuit. Also it could be so that your crystal is damaged already. Perhaps you shall try another one (look for scrap electronic clocks around :) Also to exclude any programming error, try proven to work LED blink code from source code examples: msp430g2xx3_ta_04.c 

    Kevin Peffers said:
    Abandoning. Will develop using SMCLK. Thanks for two responses.

    DCO is kind of inaccurate even when DCO factory calibration used. Many launchpad users soldered crystal w/o any problems, you shall be able too.

**Attention** This is a public forum