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.

CCS/MSP430G2553: Measuring a signal from Timer_A with an oscilloscope

Part Number: MSP430G2553

Tool/software: Code Composer Studio

Hi there,

I am recently working with the Timer_A interrupt.

Hardware settup: includes a 32 kHz external crystal connected to XIN and XOUT (I am working with the launch pad). Also the RXD and TXD Jumpers are configurated for USB UART communication. Workinstation is a Laptop.

Software: The software uses the extern source to generate the ACLK signal to suply the Timer_A. I use the timer in a compare mode to generate a 1 Hz frequency and would love to see that on my oszilloskop. In generall the code works and a LED which toggles in this frequency works. For messuring I toggle P1.5 with the 1 Hz frequency as well.

Messuring settup: The P1.5 and the upper J6 GND are connected to my oszilloskop.

Problem: Funny thing is, that the toggling LED stops if i connect GND. Also I am not able to see the frequency on the oszilloskopes display. Also funny is that i am working on a laptop connected with the launchpad. If i connect my recharger to my laptop the msp led stops blinking as well. I suppose its something with the ground of the device but i have no clue how to interprete it.

Can please anybody help me with that? It drives me crazy!


An image of my messure setup:

From time to time the messurement works. But as seen it shows a 1 Hz frequency even if i chose a compare value of 32000/2 so it should actually be 2 Hz. Still my setup is very sensitive about the ground pin. if i touch it or remove the ground connection to my osci, the behavior changes.


To make it complete, here my code:

#include <msp430.h>
#define LED_rot BIT0
#define LED_gruen BIT6
#define Button BIT3
#define Testpoint BIT5

bool schalter =true;

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 
  P1DIR = LED_rot + LED_gruen + Testpoint; // P1.0 output
  P1OUT = 0;
 
  //Button setup
  P1REN = Button;                 // Enable internal pull-up/down resistors
  P1OUT = Button;                 //Select pull-up mode for P1.3
  P1IE = Button;                       // P1.3 interrupt enabled
  P1IES = Button;                     // P1.3 Hi/lo edge
  P1IFG &= ~Button;                  // P1.3 IFG cleared
 
  //ACLK with LFXT1CLK; 32768 Hz external crystal
  BCSCTL1 = 0;
  BCSCTL1 |= XT2OFF;
  BCSCTL2 = 0;
  BCSCTL3 =0;
  BCSCTL3 |= XCAP_0;
 
  //Compare value -> 1 Hz Toggle frequence
  TACCR0 = 32768 / 2;
 
  // C/C Register settings: no Capture; compare mode;  
  TACCTL0 = CM_0 + CCIE;
 
  //Timer A setiings: Source = ACLK; Upmode; Interrupt enabled
  TACTL = 0;
  TACTL = TASSEL_1 + MC_1;

  __bis_SR_register(GIE);       // Enter LPM3 w/ interrupt
 
  while(1)
  {
  }
}

// Timer A0 interrupt service routine
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_CCR0_ISR (void)
{
    P1OUT ^= LED_rot;
    P1OUT ^= Testpoint;
}

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
    if ( schalter )
    {
        TACTL ^= MC_1;
        schalter = false;
        P1OUT ^= LED_gruen;
    }
    else
    {
        TACTL ^= MC_1;
        schalter = true;
        P1OUT ^= LED_gruen;
    }
    P1IES ^= Button;                     // P1.3 Hi/lo edge
    P1IFG &=~Button;                        // P1.3 IFG cleared
}

  • I don't understand your setup:

    Your write you are using a crystal connected to XIN and XOUT, and at the same time you are using an external source to generate ACLK?
    That is somehow contradicting...
    Which source are you using actually for ACLK?

    Lukas
  • The source for the ACLK is the external crytal which is connected to XIN and XOUT. Sorry for missleading phrasing.
  • Is it a TI board or do you use an own one?

    Problem: Funny thing is, that the toggling LED stops if i connect GND.
    GND of the power supply to the board - is that what you mean?
  • I am using the MSP-EXP430G2 LaunchPad from TI. The ground connection of my osci is connected with J6 ground. J6 is ment to be used for powersupply if usb is not used. Nevertheless the same event occures if i use GND the Pin listed next to the GPIOs.
  • I uploaded a picture of my hardware setup, perhaps this makes it more clear.
  • Your crystal is connected with fairly long wires, so might be susceptible to disturbance from external noise sources. Additionally, your program isn't checking the oscillator fault flag, and doesn't wait for the oscillator to stabilise on startup.

    Quoting from the MSP430G2xxx Family User's Guide:

    MSP430G2xxx Family User's Guide said:
    NOTE: LFXT1 Oscillator Characteristics

    Low-frequency crystals often require hundreds of milliseconds to start up, depending on the crystal.

    Ultralow-power oscillators such as the LFXT1 in LF mode should be guarded from noise coupling from other sources. The crystal should be placed as close as possible to the MSP430 with the crystal housing grounded and the crystal traces guarded with ground traces.

  • Thank you for the help, it finally works. I exchanged the default oscillator from TI with another one and soldered it directly on the board, that worked.
    I read that the oscillator fault flag is not supposed for low frequencies. Its about the OFIFG flag in the IFG1 register, isnt it?

  • Jan Wagner7 said:
    I read that the oscillator fault flag is not supposed for low frequencies. Its about the OFIFG flag in the IFG1 register, isnt it?

    Yes, the OFIFG bit is what I'm referring to. It will be set for the crystal oscillator whatever mode it's in: even at 32768-Hz. Perhaps what you read was referring to the VLO instead (which you're not using).

**Attention** This is a public forum