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.

Getting the maximum speed out of MSP430G2553 16MHz

Other Parts Discussed in Thread: MSP430G2553

I am failing to set MSP430 to it's maximum speed of 16MHz

I am only getting 1.3MHz. I use CCS and the following code. As you see in the comments I have already tried a lot:

 

#include <msp430.h>

int main(void) {

    WDTCTL = WDTPW | WDTHOLD;

// Stop watchdog timer

BCSCTL1 = CALBC1_16MHZ;

// Set range

//DCOCTL = 0x00;  // Set DCO step and modulation

//BCSCTL2 =0;

DCOCTL = CALDCO_16MHZ; 

// Set DCO step and modulation 

// raising SMCLK freq to abou 10Mhz

 //BCSCTL1 = RSEL3 + RSEL2 + RSEL1 + RSEL0;

 //DCOCTL = DCO0 + DCO1 + DCO2;

// BCSCTL1 = 0xFF; // RSEL3 + RSEL2 + RSEL1 + RSEL0;

//DCOCTL = DCO0 + DCO1 + DCO2; 

//CSCTL1 |= (DCORSEL|DCOFSEL0);         // select 20 MHz

 //CSCTL3 &= ~(DIVM0|DIVM1|DIVM2|DIVS0); // divider


    P1DIR |= (BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5);

    P2DIR |= (BIT0 + BIT3);

    P1OUT &= ~(BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5);   

while(1){

    P1OUT ^= BIT5; // I can't get a higher pin oscillation than 1.3MHz on the oscilloscope ; I expected around 8 MHz for one cycle on, one cycle off , am I wrong?

    }

return 0;

}

 

 

  • Ubre Barseph said:
    while(1){
    
        P1OUT ^= BIT5; // I can't get a higher pin oscillation than 1.3MHz on the oscilloscope ; I expected around 8 MHz for one cycle on, one cycle off , am I wrong?
    
        }

    The disassembly of the loop above is as follows:

    naken430asm said:
    0xe084: 0xe0f2 xor.b #0x20, &0x0021                     5
    0xe086: 0x0020
    0xe088: 0x0021
    0xe08a: 0x3ffc jmp 0xe084  (offset: -8)                 2
    

    The column on the right is the number of cycles taken for each instruction. This information can also be found by looking up the instructions in MSP430x2xx Family User's Guide section 3.4.4 (CPU->Instruction Cycles and Lengths).

    Since the loop is 7 cycles long I'd expect to see a flash frequency of 16000000/(7*2), which is 1142857Hz. That's in the ballpark of 1.3MHz, though I'm not sure how you're managing to get it to run quite that fast!

  • Robert Cowsill said:
    That's in the ballpark of 1.3MHz, though I'm not sure how you're managing to get it to run quite that fast!

    Depends on what he is measuring the frequency with. I suspect he's trying to read the period manually off the oscilloscope and inverting the number to get a (rough) frequency.

    Ubre Barseph said:
    P1DIR |= (BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5);
    P2DIR |= (BIT0 + BIT3);
    P1OUT &= ~(BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5);

    Don't use addition for the bit fields. Use the bitwise "or" operator. Please see this recent thread: http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/256498/899629.aspx#899629

  • Robert, Brian,

    That makes a lot of sense now. Yes, I was measuring with an oscilloscope, maybe the frequency measurement wasn't quite exact but close enough :)

    Thanks for the valuable information!!

  • If you are not measuring execution time but just clock frequencies, then you can use ACLK and SMCLK output option:

    P1DIR |= 0x13; // P1.0,1 and P1.4 outputs
    P1SEL |= 0x11; // P1.0,4 ACLK, SMCLK output

  • Thank you Ilmars. Very cool: I tried the above code and it gave me quite exactly 16MHz on pin P1.4. of the device. It's a great,easy way to test the device frequency!

     

    // For the record, here is the complete test program to observe 16MHz on P1.4 of the MSP430G2553

    #include <msp430.h>

    main(void) {

        WDTCTL = WDTPW | WDTHOLD;

        BCSCTL1 = CALBC1_16MHZ;

        DCOCTL = CALDCO_16MHZ;

        P1DIR |= 0x13; // P1.0,1 and P1.4 outputs

        P1SEL |= 0x11; // P1.0,4 ACLK, SMCLK output

    return 0;

    }

     

    Thanks

**Attention** This is a public forum