The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.
how to generate variable pwm using msp430x20x1 - madh_86 - Aug 25 23:59:08 2009
Hi,I am new to msp430 i dont have any knowledge on embedded programming kindly help me, i
am working on msp430X20X1 to generate varibale pwm but as i debug the program when i am
checking output with CRO at P1.2 i am unable to get varibale pwm i am getting constant
duty cycle of first CCR1 vaule. once the timer is configured in OUTMODE_7 i am unable to
stop it even with CCIE it is not going to ISR.How to use ISR that will return a value with
updated CCR1 register.plz help me out.....
This is the program what i have coded
#include
void main(void)
{
int i,j=90;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x0C; // P1.2 and P1.3 output
P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 options
CCR0 = 512-1; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
while(1==1)
{
if(CCR1
{
CCR1 = j+30; // CCR1 PWM duty cycle
}
else
{
CCR1=90;
}
}
}_BIS_SR(CPUOFF); // Enter LPM0
}
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )
Re: how to generate variable pwm using msp430x20x1 - old_cow_yellow - Aug 26 2:37:52 2009
Very strange code!
You set CCR0 to 512-1 and use up mode, it takes 512 clocks to generate a single pulse. But
before that pulse is generated, you "changed" the pulse-width (CCR1)dozens of times. Each
time you "changed" it to the same value 90+30=120. So goes the next pulse, and the next,
etc. Thus the period is always 512, and the pulse width keeps "changing" all the time to
the same 120.
--- In m...@yahoogroups.com, "madh_86"
wrote:
>
> Hi,I am new to msp430 i dont have any knowledge on embedded programming kindly help me,
i am working on msp430X20X1 to generate varibale pwm but as i debug the program when i am
checking output with CRO at P1.2 i am unable to get varibale pwm i am getting constant
duty cycle of first CCR1 vaule. once the timer is configured in OUTMODE_7 i am unable to
stop it even with CCIE it is not going to ISR.How to use ISR that will return a value with
updated CCR1 register.plz help me out.....
>
> This is the program what i have coded
>
> #include void main(void)
>
> {
>
> int i,j=90;
>
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
>
> P1DIR |= 0x0C; // P1.2 and P1.3 output
>
> P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 options
>
> CCR0 = 512-1; // PWM Period
>
> CCTL1 = OUTMOD_7; // CCR1 reset/set
>
> TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
>
> while(1==1)
>
> {
>
> if(CCR1
>
> {
>
> CCR1 = j+30; // CCR1 PWM duty cycle
>
> }
>
> else
>
> {
>
> CCR1=90;
>
> }
>
> }
>
> }_BIS_SR(CPUOFF); // Enter LPM0
>
> }
>
------------------------------------
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )