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.

The output of MSP430G2231 38KHZ 1% duty cycle?

Other Parts Discussed in Thread: MSP430G2231, MSP430G2353

The output of MSP430G2231 38KHZ 1% duty cycle?

  • For PWM wave, the frequency = clock source/CCR0, duty cycle = CCR1/CCR0. For example, to output 38KHZ 1% duty cycle PWM with 8MHz SMCLK source, then CCR0= 8000/38=211, CCR1 = 21.  Please see below code example for reference.

    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

         //8Mhz
         if (CALBC1_8MHZ==0xFF) // If calibration constants erased
         {
              while(1); // do not load, trap CPU!!
         }
         DCOCTL = 0; // Select lowest DCOx and MODx settings
         BCSCTL1 = CALBC1_8MHZ; // Set range
         DCOCTL = CALDCO_8MHZ; // Set DCO step + modulation 

      P1DIR |= 0x0C;                            // P1.2 and P1.3 output
      P1SEL |= 0x0C;                            // P1.2 and P1.3 TA1/2 otions
      CCR0 = 211;                               // PWM Period/2
      CCTL1 = OUTMOD_6;                         // CCR1 toggle/set
      CCR1 = 21;                                // CCR1 PWM duty cycle
      TACTL = TASSEL_2 + MC_3;                  // SMCLK, up-down mode
    
      __bis_SR_register(LPM3_bits);             // Enter LPM3
    }
    

     B.R

    Winter

  • Thank you for your answer, this program is not compiled successfully.

    Need to work in low power mode, thank you

  • Sorry, the MSP430G2231 only provides 1MHz DCO Calibration Data. To output 38KHZ 1% duty cycle PWM with 1MHz SMCLK source, then CCR0= 1000/38=26.3, CCR1 = 2.63. Due to the CCRx registers only can be set to integer value, using this configuration will cause big errors. So, recommend using another part which supports 8MHz clock, such as MSP430G2353.

**Attention** This is a public forum