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.
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
**Attention** This is a public forum