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.

Achieving 16 MHz Clock

Other Parts Discussed in Thread: MSP430F2618

Hi,

I'm a graduate student and I'm pretty new to some really basic concepts when dealing with MCUs. I just want to get the most out of my MSP430f2618 I'm using in an embedded project. I'm essentially sampling a mixed signal using the ADC12 module, sending the data back to MATLAB on my CPU, and performing an FFT on it to get the 400Hz component. What I need is a slightly higher sampling speed. I have the master clock set at 8MHz and the best sampling rate I seem to be able to get is 33ksps when the datasheet says its 200ksps. I'm fairly certain I've maxed out the settings and I'm sampling at increments set by Timer A. I directly store the data to an integer array.

What I'm thinking is that if I can up the master clock speed to 16MHz I can at least double my sampling rate. The problem is that I can't seem to find any info on how to actually set the master clock to 16MHz and what type of external crystal needs to be added (and how).

Thanks for any and all input.

  • Hi Andrew,

    The MSP430F2618 comes with calibration values for the internal DCO, one of which is for 16MHz. You can find out how to use the calibration values through the TI example code I'm attaching. Just substitute CALBC1_8MHZ and CALDCO_8MHZ with CALBC1_16MHZ and CALDCO_16MHZ.

    Tony

    //******************************************************************************
    //  MSP430x26x Demo - Basic Clock, Output Buffered SMCLK, ACLK and MCLK/10
    //
    //  Description: Buffer ACLK on P5.6, SMCLK(DCO) on P5.5, MCLK on P5.4 and 
    //  MCLK/10 on P5.3.
    //  ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = CALxxx_8MHZ = 8MHz
    //  //* External watch crystal on XIN XOUT is required for ACLK *//
    //
    //            MSP430F261x/241x
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P5.6|-->ACLK = 32kHz
    //            |             P5.5|-->SMCLK = 8MHz
    //            |             P5.4|-->MCLK = DCO
    //            |             P5.3|-->MCLK/10
    //
    //  B. Nisarga
    //  Texas Instruments Inc.
    //  September 2007
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
    //******************************************************************************
    #include "msp430x26x.h"
    
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop Watchdog Timer
      if (CALBC1_8MHZ ==0xFF || CALDCO_8MHZ == 0xFF)                                     
      {  
        while(1);                               // If calibration constants erased
                                                // do not load, trap CPU!!
      }  
      BCSCTL1 = CALBC1_8MHZ;                    // Set DCO to 8MHz
      DCOCTL = CALDCO_8MHZ;
      P5DIR |= 0x78;                            // P5.6,5,4,3 outputs
      P5SEL |= 0x70;                            // P5.6,5,4 options
    
      while (1)                                 // 10 MCLK cycle loop
      {
        P5OUT |= 0x08;                          // P5.3 = 1
        P5OUT &= ~0x08;                         // P5.3 = 0
      }
    }
    

  • It works! I was calibrating to 8MHz with this code:

      if (CALBC1_8MHZ ==0xFF || CALDCO_8MHZ == 0xFF)                                     
      {  while(1);                       // If calibration constants erased
                                                // do not load, trap CPU!!
      }  
      BCSCTL1 = CALBC1_8MHZ;                    // Set DCO to 8MHz
      DCOCTL = CALDCO_8MHZ;

    but I didn't see the calibration for 16MHz in the header for some reason. Thanks for your help

  • Andrew DeRouin said:
    but I didn't see the calibration for 16MHz in the header for some reason. Thanks for your help

    Are you using the right header file? It shoudl be there, else it is a mistake and someone forgot to add them. However, you may be able to define them on your own. It's just the next memory address after the 1, 8 and 12MHz calibration values.

    Keep in mind that this settign isn't exactly 16MHz. First, the DCO interpolates between two different frequencies, so the calibrated value is jsut an average frequency across 2ms gating time. And also, it might be possible that exact 16MHz average are impossible to do on thsi specific MSP. The datasheet specifies 15.84..16.16MHz on 3V/25°C and 15MHz to 16.5MHz for full operating range.

  • I'm running the device on 3.3V. It is in the header, I just didn't see it before because, as you guessed I was using the wrong one originally. My project started on the experimenter's board that uses the FG4618 chip, and that header file only goes up to 8MHz. The information about the DCO shifting between those two frequencies is really helpful. Could you point me to a reference that explains it? Is that information from the header file?

  • Hi Andrew,

    It's in the device datasheet under "Calibrated DCO frequencies ".

    Tony

  • Andrew DeRouin said:
    The information about the DCO shifting between those two frequencies is really helpful. Could you point me to a reference that explains it?

    That's part of the DCO explanation in the users guide. The section about DCO modulation.

    The gating time is part of the calibrated DCO value specs in the datasheet. However, if not using the 4x/5x family FLL, modulation and therefore average frequency should be stable across 32 clock pulses (as this is the length of the modulation pattern)

**Attention** This is a public forum