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.

Clock output on MSP430

Other Parts Discussed in Thread: CC2520, MSP430F2618, MSP430F2002

Hi,

I am using CC2520 Development kit with MSP430F2618. I am using Sample Application (simple collector and simple sensor setup). I have my own sensor on an external PCB.

I need a clock output constantly from MSP430 in order to make my sensor working properly (because of sensors internal logic). I have configured pin P5.4 as clock, but I don't get a constant output. On the osciloscope I see that clock is active during SPI transmissions and probably CC2520 operations.

Is it possible to have clock output all the time?

Thanks,

Ivan.

  • You probably set up P5.4 to output MCLK. Thus it will stop when the CPU is in sleep mode or is stopped by the debugger. You could try SMCLK or ACLK instead. Be aware of power consumption.

  • Wow, that was fast... [:)]

    Thanks for the quick reply. The thing is that I have already tried this. Power consumption is not a problem. I have tried SMCLK ( it is configured by defualt during DCO calibration on pin P1.4) but the signal is also not constant. There are periods of time without a clock.

    Additional clarification, I need 5MHz clock. I have changed DCO frequency to 5MHz so the MCLK and SMCLK could be used as main clock for my sensor.

     

  • I have also noticed that during the initialization the clock runs normaly and after couple of seconds I start loosing it. Maybe some power optimization part of the SW does this?

  • Which low power mode is the chip "resting" in, anything greater than LPM1, and you lose your clocks.  Also, are you watching the oscilloscope while the chip is in debugging mode, because the clocks stop when you stop at a breakpoint in debugging mode.

  • Hi sparkchaser,

    Thanks for the tip.

    I have checked the application. POWER_SAVING option was defined, so the OSAL task suspended the MCU and MCLK. Now, I have a constant output on port P5.4. This is ok for now since I don't care about the power consuption at this time. I will optimize power consuption by using SMLCK instead of MCLK and LPM0 or LPM1.

     

    Thanks again.

    Best regards,

    Ivan.

  • Hi sparkchaser,

    Thanks for the tip.

    I have checked the application. POWER_SAVING option was defined, so the OSAL task suspended the MCU and MCLK. Now, I have a constant output on port P5.4. This is ok for now since I don't care about the power consuption at this time. I will optimize power consuption by using SMLCK instead of MCLK and LPM0 or LPM1.

     

    Thanks again.

    Best regards,

    Ivan.

  • Hi Guys, am using MSP430F2002

    I need help , I am writing a code to PWM , the problem is that I have made 3 prototype board and so far all of then has  a different PWM frequency , one for example PWM with 228.3Hz and the other is 246Hz , this difference is giving me a problem . I am new in MSP430 , so can I some how have a more accuracy DCO without crystal ? I read that I could use VLO as clock source for the DCO , can I do that , any idea ? or sample code to help ?

    Thanks

    #include "msp430x20x2.h"
      unsigned int Solar = 0;                                           // unsigned int Solar = 0;                                                   
      unsigned int Battery = 0;                                        // unsigned int Battery = 0;                                                 
      unsigned char ch_counter = 0;                           // unsigned ch_counter = 0;
      unsigned int Timer = 0;                                        // unsigned int Timer = 0;
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                         // Stop WDT;
      ADC10CTL0 = ADC10SHT_2 + MSC + SREF_1 + REFON + ADC10ON + ADC10IE ;  // ADC10ON, interrupt enabled;
      ADC10CTL1 = INCH_1 ;                                                       // input A1;
      ADC10CTL1 |= ADC10SSEL_0;                                                  // set clock to ADC10OSC;
      ADC10AE0 |= 0x03;                                                          // PA.1 ADC option select;
      P1OUT &= ~ 0x0C;                                                           // this sets the output low GPIO;
      P1DIR |= 0x0C;                                                             // Set P1.2 to output direction;
      P1SEL &= ~0x04;                                                            // Turn LED OFF;
     //*****************************************************************************
       while(1)
        ADC10CTL0 |= ENC + ADC10SC;                                              // Sampling and conversion start;
        __bis_SR_register(CPUOFF + GIE);                                         // LPM0, ADC10_ISR will force exit; 
      CCR0 = 5000;                                                               // PWM Period
      CCTL1 = OUTMOD_7;                                                          // CCR1 reset/set
       if (Battery < 626)
         Timer = 3000;
        else
          Timer = 1000;
      CCR1 = Timer ;                            // CCR1 PWM duty cycle
      TACTL = TASSEL_2 + MC_1;                  // SMCLK, up mode 
          P1SEL |= 0x04;                                                         // Turn  LED ON;
          i = 1;                                                                 // Set i = 1;
         }
    // ADC10 interrupt service routine
    #pragma vector=ADC10_VECTOR
    __interrupt void ADC10_ISR(void)
    {
       switch (ch_counter)
       {
       case 0:
         Solar = ADC10MEM;                                                       // Save CH0 results
         ADC10CTL0 &= ~ENC;
         ADC10AE0 &= ~ 0x02;                                                     // Disable chanel A1
         ADC10CTL1 &= ~ INCH_1;                                                  // Disable external input A1
         ch_counter++;
         ADC10CTL1 |= INCH_0;                                                    // Enable chanel A0
         ADC10AE0 |= 0x01;                                                       // Enable external input A0
           
         break;
       case 1:
         Battery = ADC10MEM;                                                     // Save CH1 results
         ADC10CTL0 &= ~ENC;
         ch_counter = 0;
         ADC10AE0 &= ~ 0x01;                                                     // Disable chanel A0  MRC
         ADC10CTL1 &= ~ INCH_0;                                                  // Disable external input A0  
         ADC10CTL1 |= INCH_1;                                                    // Enable chanel A1
     
         break;
       }   
       __bic_SR_register_on_exit(CPUOFF);                                         // Clear CPU  OFF bit from 0(SR)
    }

  • Marcelo,

    The reason you are getting different frequencies between two chips is because you are using the default DCO frequency.  Because the frequency is determined by an internal RC network, and because that R and C is slightly different from chip to chip, you get slighly different default frequencies from chip to chip.  Luckily for us, each MSP is calibrated at the factory for 1, 8, 12, and 16 MHz (+/- 1%), and these settings are stored into the MSP's information memory so that user's can copy those calibrated values into the DCO's configuration registers at run time.  The User's Guide gives a description of how these registers can be accessed, but to put it simply, just include these two lines of code to configure the DCO:

    for 1MHz

      DCOCTL = CALDCO_1MHZ;
      BCSCTL1 = CALBC1_1MHZ;

    for 8 MHz

      DCOCTL = CALDCO_8MHZ;
      BCSCTL1 = CALBC1_8MHZ;

    and so on for 12 and 16 MHz.

    Do not use the VLO, its design goal was low power, not accuracy.

     

    Sparkchaser

  • Sparkchaser

    Thanks for your help, here is what I did , right after a stop watch dog .

    What do you think ?

    I tried and is working actually my PWM now is 200.4Hz , so I have uploaded in 2 boards and is the same frequency in both .

    Thanks

     

     

     

     

    #include "msp430x20x2.h"
      unsigned int Solar = 0;                                           // unsigned int Solar = 0;                                                  
      unsigned int Battery = 0;                                        // unsigned int Battery = 0;                                                
      unsigned char ch_counter = 0;                           // unsigned ch_counter = 0;
      unsigned int Timer = 0;                                        // unsigned int Timer = 0;
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                         // Stop WDT;
      DCOCTL = CALDCO_1MHZ;
      BCSCTL1 = CALBC1_1MHZ;
      ADC10CTL0 = ADC10SHT_2 + MSC + SREF_1 + REFON + ADC10ON + ADC10IE ;  // ADC10ON, interrupt enabled;
      ADC10CTL1 = INCH_1 ;                                                       // input A1;
      ADC10CTL1 |= ADC10SSEL_0;                                                  // set clock to ADC10OSC;
      ADC10AE0 |= 0x03;                                                          // PA.1 ADC option select;
      P1OUT &= ~ 0x0C;                                                           // this sets the output low GPIO;
      P1DIR |= 0x0C;                                                             // Set P1.2 to output direction;
      P1SEL &= ~0x04;                                                            // Turn LED OFF;
     //*****************************************************************************
       while(1)
        ADC10CTL0 |= ENC + ADC10SC;                                              // Sampling and conversion start;
        __bis_SR_register(CPUOFF + GIE);                                         // LPM0, ADC10_ISR will force exit;
      CCR0 = 5000;                                                               // PWM Period
      CCTL1 = OUTMOD_7;                                                          // CCR1 reset/set
       if (Battery < 626)
         Timer = 3000;
        else
          Timer = 1000;
      CCR1 = Timer ;                            // CCR1 PWM duty cycle
      TACTL = TASSEL_2 + MC_1;                  // SMCLK, up mode
          P1SEL |= 0x04;                                                         // Turn  LED ON;
          i = 1;                                                                 // Set i = 1;
         }
    // ADC10 interrupt service routine
    #pragma vector=ADC10_VECTOR
    __interrupt void ADC10_ISR(void)
    {
       switch (ch_counter)
       {
       case 0:
         Solar = ADC10MEM;                                                       // Save CH0 results
         ADC10CTL0 &= ~ENC;
         ADC10AE0 &= ~ 0x02;                                                     // Disable chanel A1
         ADC10CTL1 &= ~ INCH_1;                                                  // Disable external input A1
         ch_counter++;
         ADC10CTL1 |= INCH_0;                                                    // Enable chanel A0
         ADC10AE0 |= 0x01;                                                       // Enable external input A0
          
         break;
       case 1:
         Battery = ADC10MEM;                                                     // Save CH1 results
         ADC10CTL0 &= ~ENC;
         ch_counter = 0;
         ADC10AE0 &= ~ 0x01;                                                     // Disable chanel A0  MRC
         ADC10CTL1 &= ~ INCH_0;                                                  // Disable external input A0 
         ADC10CTL1 |= INCH_1;                                                    // Enable chanel A1
     
         break;
       }  
       __bic_SR_register_on_exit(CPUOFF);                                         // Clear CPU  OFF bit from 0(SR)
    }

  • Hello,

    Trying to achieve low power consumption with MSP430F2002 by using VLO, however cannot turn DCO off

    BCSCTL3 |= LFXT1S_2;

    BCSCTL2 |= SELM_3 + DIVM_1;

    __bis_SR_register(SCG1 + SCG0);

    Thank you.

  • Igor Radutnuy said:
    Trying to achieve low power consumption with MSP430F2002 by using VLO, however cannot turn DCO off

    You just got an answer in your own thread. Please don't post the same question in more than one thread, especially not if it revives an old thread with a different topic. It only reduces your chances of getting an answer.

  • Got it, I am new to community and did not realize groups cross talking.

       

**Attention** This is a public forum