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
}