Hello,
I am using msp430f5659 for PWM waveform generation. I have used the code given below to generate pwm using timer.
PWM_PINDIR;
PWM_PINMODESELECT; //Select pin 1.6 as our PWM output.
TA0CCR0 = 1000; //Set the period in the Timer A0 Capture/Compare 0 register to 1000 us.
TA0CTL = TASSEL_2+ MC_1 + TACLR ; //TASSEL_2 selects SMCLK as the clock source,
//and MC_1 tells it to count up to the value in TA0CCR0 upmode, clear TAR.
TA0CCTL1 = OUTMOD_7;
TA0CCR1 = 500; //The period in microseconds that the power is ON. It's half the time,
//which translates to a 50% duty cycle.
//TA0CTL = TASSEL_2 + MC_1; //TASSEL_2 selects SMCLK as the clock source, and
//MC_1 tells it to count up to the value in TA0CCR0.
TA0CCTL0 = CCIE; // CCR0 interrupt enabled
__bis_SR_register(LPM0_bits); //Switch to low power mode 0.
// Timer0 A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) TIMER0_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
PWM_PINTOGGLE; // Toggle P1.6
__bic_SR_register(LPM0_bits);
}
I am getting freq of 12kHz of the generated PWM but my SMCLK is oscillating at 12MHz. How can i get the higher freq?
I have tried to change the output PWM freq by changing the value in the ID of TA0CTL register but it does not affect the freq.
How can I change the freq of the PWM? Which register value I have to modify to get desired freq.