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.

msp430g2433 pwm SHARING USING TA0 TIMER

I am sorry if  this is discussed before.

I have two software functions using two independent PWM outputs.

Function 1 using P1.2 as PWM output from timer0

Function 2 using P1.6 as PWM output from timer0.

This MCU does have 3 CCR.

What i want is to disable P1.2 completely when function 2 is in command and vice-versa.

here is my PWM code for function 1 and 2

TA0CCR0 = 159; // PWM Period approx 50KHz (160-1=159)
TA0CCR1 = 80; // CCR1 PWM duty cycle
TA0CCTL1 = OUTMOD_7; // CCR1 reset/set
TA0CTL = TASSEL_2 + MC_1; // SMCLK, Up Mode

and i initialized P1.2 and P1.6 as:

P1SEL = 0x44; 
P1DIR = 0x46; 

Thanks,

Abhishek

 

  • There are two simple (and many more less simple) ways you can do this.
    Either you switch the CCR you don’t need to OUTMOD_0 and set the OUT bit to the value the output shall have, or you switch the port pin from timer to GPIO mode by clearing the PxSEL bits. Then you can control whether the pin shall be high-impedance (input) or low or high static output.

  • The code you have shown is generating only one PWM signal and it drives both P1.2 and P1.6 at the same time.The period is controlled by CCR0 while the duty cycle is controlled by CCR1. CCR2 is not used.

    If you want that signal to appear on P1.2 only and leave P1.6 in high-impedance, you could simply set: P1DIR=0x06;

    Conversely, If you want that signal to appear on P1.6 only and leave P1.2 in high-impedance, you could simply set: P1DIR=0x42;

  • Good catch, I totally missed that both outputs belong to the same CCR.

**Attention** This is a public forum