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.

msp430f2618 calibration problem..

Other Parts Discussed in Thread: MSP430F2618, MSP430F2274

hi all.

  i just tried to run my controller in 16MHZ via internal oscilator  by means of software but am getting only 1.3MHZ.. I just enclosed my code below..please check it and tell me the error...

#include  <msp430f2618.h>


void main(void)

{
    
     WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer
      BCSCTL1 = CALBC1_16MHZ;
      DCOCTL  = CALDCO_16MHZ;
      P1DIR |= 0xFF;
      P1OUT =0x00;
      P1SEL = 0x00;
 
      while(1)
      {
          
      P1OUT ^= BIT3;
          
      }
    
    
}

  • Hello,

    it looks good, i am doing the same thing with my MSP430F2274, but I am sure my controller has the calibrated 8 MHz in his memory.

    If you are sure your controler has it as well, then it should work.

    Ho do you meassure your clock? just by switching a GPIO pin wont show you your actual MCLK .

    Try implementing a timer which counts with your 16 MHz, then switch the GPIO in a timer interrupt, so you are sure what clock you will get.

    Hope that helped you.

    Greetings, Seb

  • do you have any sample code for this

  • Let's look at your code how it looks in assembly:

    L1:
    XOR #0x08,P1OUT
    JMP L1

    the XOR, if using the constant generator, requires 4 clock cycles: read instruction, read P1Out address, read P1OUT content, perform the XOR and write back to P1OUT.
    The JMP requires 2 clock cycles. One for the instruciton, one for performing the jmp.

    makes 6 MCLK cycles for toggling the output pin, and 12 MCLK cycle for a complete wave. So on 16MHz MCLK you'll see 16/12 = 1.333MHz output frequency. Fits your observation.

  • thanks for your reply ..and one more thing where can i get this kind of information like clock cycles for my every c code

  • karthik raja said:
    where can i get this kind of information like clock cycles for my every c code

    Not for C code (I played 'compiler' to get it). This info is available in the users guide in the section about th eCPU. But it is only available for assembly codes (since that is what the CPU finally executes). Which assembly code is generated by teh compiler depends on the compiler, its optimization skill, your project stettings etc.

    In this case, there were not many possible outcomes, so it was easy to do a 'human compile' and get a quick result. On a larger program, you can use the disassembnly view in the debugger to see what assembly code the compiler generated for your C source. However, after optimization, it is not as easy to see what assembly code is generated for what C code (as optimization groups things, and delays otehrs, fo rsmallest and fastest code)

    It is perhaps possible (I never tried, as I don't use them) to get a complete disassembly listing generated by IAR or CCS. MSPGCC (which I use) does this by default. But don't ask me how to enable this. Maybe in the compiler/linker options (liek the 'generate map file' option).

**Attention** This is a public forum