Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430





Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | MSP430 | how to genearate varibale PWM

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 genearate varibale PWM - yamsani madhu sudhan - Aug 25 23:59:07 2009

Hi,I am new to msp430 i dont have any knowledge on embedded programming kin=
dly 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=A0i am getting constant duty cycle of first=A0CCR1=A0vaul=
e.=A0once 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 wi=
th updated CCR1 register.plz help me out.....
=A0
This is the program what i have coded
=A0
#include
void main(void)
{
int i,j=3D90;
WDTCTL =3D WDTPW + WDTHOLD; // Stop WDT
P1DIR |=3D 0x0C; // P1.2 and P1.3 output
P1SEL |=3D 0x0C; // P1.2 and P1.3 TA1/2 options
CCR0 =3D 512-1; // PWM Period
CCTL1 =3D OUTMOD_7; // CCR1 reset/set
TACTL =3D TASSEL_2 + MC_1; // SMCLK, up mode
while(1=3D=3D1)
{
if(CCR1 {
CCR1 =3D j+30; // CCR1 PWM duty cycle
}
else
{
CCR1=3D90;
}
}
}_BIS_SR(CPUOFF); // Enter LPM0
}
See the Web's breaking stories, chosen by people like you. Check =
out Yahoo! Buzz. http://in.buzz.yahoo.com/

[Non-text portions of this message have been removed]

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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


Re: how to genearate varibale PWM - "nss...@rocketmail.com" - Aug 26 10:54:35 2009

Greetings, I am sorry for bad English, I read is better than I speak. I think it is possible to use an example hardware pwm (http://www.ti.com/litv/zip/slac080e) msp430x20x3_ta_16.c . This example works with msp430f2001, msp430f2002 too, it is necessary to replace only #include on #include . CCR0 - a basis cycle, CCR1 - duty a cycle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from TI.COM) :

#include

void main(void)
{
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
CCR1 = 384; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode

// _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory at debugging

while(1){
CCR0=10000;
CCR1=1000; // 10000/1000= pwm 10%
//CCR1=5000; // pwm 50%

}

}
If necessary it is possible to add interrupt service routine.
pwm all time while works Timer_A, values CCR0 works and CCR1 vary at any moment, when necessary.
------------------------------------



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

Re: how to genearate varibale PWM - old_cow_yellow - Aug 26 14:47:43 2009

See an example in the file area.

http://f1.grp.yahoofs.com/v1/IHiVSvT_CLCKd5JuuO2yFgKC28h3iKi_YeR6DPfztNqCs-EWNymRfGw64wrojp6kCoynPm8RUnamr28fmyXS/Member%20contributions/PWM_example.c
--- In m...@yahoogroups.com, "nsspost@..." wrote:
>
> Greetings, I am sorry for bad English, I read is better than I speak. I think it is possible to use an example hardware pwm (http://www.ti.com/litv/zip/slac080e) msp430x20x3_ta_16.c . This example works with msp430f2001, msp430f2002 too, it is necessary to replace only #include on #include . CCR0 - a basis cycle, CCR1 - duty a cycle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from TI.COM) :
>
> #include void main(void)
> {
> 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
> CCR1 = 384; // CCR1 PWM duty cycle
> TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
>
> // _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory at debugging
>
> while(1){
> CCR0=10000;
> CCR1=1000; // 10000/1000= pwm 10%
> //CCR1=5000; // pwm 50%
>
> }
>
> }
> If necessary it is possible to add interrupt service routine.
> pwm all time while works Timer_A, values CCR0 works and CCR1 vary at any moment, when necessary.
>
------------------------------------



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

Re: how to genearate varibale PWM - madh_86 - Aug 27 1:48:30 2009

Thanks for the reply now i am able to vary the pwm but the width is also changing i want the width to be constant and for each successive cycle the duty cycle should vary please help me out...

#include void main(void)
> {
> 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
> CCR1 = 384; // CCR1 PWM duty cycle
> TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
>
> // _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory at debugging
>
> while(1){
> CCR0=10000;
> CCR1=1000; // 10000/1000= pwm 10%
> CCR1=5000; // pwm 50%
>
> }
>
> }
--- In m...@yahoogroups.com, "nsspost@..." wrote:
>
> Greetings, I am sorry for bad English, I read is better than I speak. I think it is possible to use an example hardware pwm (http://www.ti.com/litv/zip/slac080e) msp430x20x3_ta_16.c . This example works with msp430f2001, msp430f2002 too, it is necessary to replace only #include on #include . CCR0 - a basis cycle, CCR1 - duty a cycle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from TI.COM) :
>
> #include void main(void)
> {
> 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
> CCR1 = 384; // CCR1 PWM duty cycle
> TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
>
> // _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory at debugging
>
> while(1){
> CCR0=10000;
> CCR1=1000; // 10000/1000= pwm 10%
> //CCR1=5000; // pwm 50%
>
> }
>
> }
> If necessary it is possible to add interrupt service routine.
> pwm all time while works Timer_A, values CCR0 works and CCR1 vary at any moment, when necessary.
>
------------------------------------



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

Re: how to genearate varibale PWM - bob_shaftenkluger - Aug 27 9:49:58 2009

Hi.
I'm pretty sure the example you were shown does what you want.

CCR0=10000;
This line sets the width.

CCR1=1000; // 10000/1000= pwm 10%
This line sets the duty cycle.
If you change the right value, the pwm width should stay the same.

It does seem a little strange to set CCR0 to 512-1 just to change it very soon after though. Perhaps you will have better luck with this slighty modified version?
Or maybe I have totaly misunderstood, I am very new at this myself.

#include

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x0C; // P1.2 and P1.3 output
P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 options
CCR0 = 10000; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 0; // CCR1 PWM duty cycle, set to 0 initialy, to prevent power //on flashes etc
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode

// _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory
at debugging

while(1){
CCR0=10000; //PWM width
CCR1=1000; // 10000/1000= pwm 10% Duty cycle is this bit!
//CCR1=5000; // pwm 50%

}

}

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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

Re: how to genearate varibale PWM - old_cow_yellow - Aug 27 11:39:27 2009

[code]
//******************************************************************************
// MSP430F20xx Demo - Timer_A, PWM TA1-2, Up Mode, DCO SMCLK
//
// Description: This program generates one PWM output on P1.2 using
// Timer_A configured for up mode. The value in CCR0, 512-1, defines the PWM
// period and the value in CCR1 the PWM duty cycles.
// A 75% duty cycle on P1.2.
// ACLK = na, SMCLK = MCLK = TACLK = default DCO
//
// MSP430F20xx
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.2/TA1|--> CCR1 - 75% PWM
//
// M.Buccini / L. Westlund
// Texas Instruments, Inc
// October 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
//
// Modified but untested - by Old_Cow_Yellow
//******************************************************************************

#include // ***OCY***

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x04; // P1.2 output ***OCY***
P1SEL |= 0x04; // P1.2 TA1-out ***OCY***
CCR0 = 512-1; // PWM Period
CCTL0 = CCIE; // ***OCY***
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 384; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode

_BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
}

// All lines below are added by ***OCY***
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
CCR1++; // Increse duty cycle
if (CCR1 > CCR0) CCR1 = 51; // If too big, change to very small
}
[\code]

--- In m...@yahoogroups.com, "old_cow_yellow" wrote:
>
> See an example in the file area.
>
> http://f1.grp.yahoofs.com/v1/IHiVSvT_CLCKd5JuuO2yFgKC28h3iKi_YeR6DPfztNqCs-EWNymRfGw64wrojp6kCoynPm8RUnamr28fmyXS/Member%20contributions/PWM_example.c
> --- In m...@yahoogroups.com, "nsspost@" wrote:
> >
> > Greetings, I am sorry for bad English, I read is better than I speak. I think it is possible to use an example hardware pwm (http://www.ti.com/litv/zip/slac080e) msp430x20x3_ta_16.c . This example works with msp430f2001, msp430f2002 too, it is necessary to replace only #include on #include . CCR0 - a basis cycle, CCR1 - duty a cycle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from TI.COM) :
> >
> > #include
> >
> > void main(void)
> > {
> > 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
> > CCR1 = 384; // CCR1 PWM duty cycle
> > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> >
> > // _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory at debugging
> >
> > while(1){
> > CCR0=10000;
> > CCR1=1000; // 10000/1000= pwm 10%
> > //CCR1=5000; // pwm 50%
> >
> > }
> >
> > }
> >
> >
> > If necessary it is possible to add interrupt service routine.
> > pwm all time while works Timer_A, values CCR0 works and CCR1 vary at any moment, when necessary.
>

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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

Re: how to genearate varibale PWM - madh_86 - Aug 31 5:14:32 2009

When i have debugged the given program i am not getting the varibale PWM output once the timer has started after overflow it is not going into ISR and updating the CCR1 value please suggest me the solution.I want variable pwm like in first period 10% and second period 20% dutycycle like this so on...kindly help me out....

thanks in advance

#include // ***OCY***

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x04; // P1.2 output ***OCY***
P1SEL |= 0x04; // P1.2 TA1-out ***OCY***
CCR0 = 512-1; // PWM Period
CCTL0 = CCIE; // ***OCY***
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 384; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode

_BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
}

// All lines below are added by ***OCY***
#pragma vector=TIMERA0_ VECTOR
__interrupt void Timer_A (void)
{
CCR1++; // Increse duty cycle
if (CCR1 > CCR0) CCR1 = 51; // If too big, change to very small
}
[\code]
--- In m...@yahoogroups.com, "old_cow_yellow" wrote:
>
> [code]
> //******************************************************************************
> // MSP430F20xx Demo - Timer_A, PWM TA1-2, Up Mode, DCO SMCLK
> //
> // Description: This program generates one PWM output on P1.2 using
> // Timer_A configured for up mode. The value in CCR0, 512-1, defines the PWM
> // period and the value in CCR1 the PWM duty cycles.
> // A 75% duty cycle on P1.2.
> // ACLK = na, SMCLK = MCLK = TACLK = default DCO
> //
> // MSP430F20xx
> // -----------------
> // /|\| XIN|-
> // | | |
> // --|RST XOUT|-
> // | |
> // | P1.2/TA1|--> CCR1 - 75% PWM
> //
> // M.Buccini / L. Westlund
> // Texas Instruments, Inc
> // October 2005
> // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
> //
> // Modified but untested - by Old_Cow_Yellow
> //******************************************************************************
>
> #include // ***OCY***
>
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> P1DIR |= 0x04; // P1.2 output ***OCY***
> P1SEL |= 0x04; // P1.2 TA1-out ***OCY***
> CCR0 = 512-1; // PWM Period
> CCTL0 = CCIE; // ***OCY***
> CCTL1 = OUTMOD_7; // CCR1 reset/set
> CCR1 = 384; // CCR1 PWM duty cycle
> TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
>
> _BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
> }
>
> // All lines below are added by ***OCY***
> #pragma vector=TIMERA0_VECTOR
> __interrupt void Timer_A (void)
> {
> CCR1++; // Increse duty cycle
> if (CCR1 > CCR0) CCR1 = 51; // If too big, change to very small
> }
> [\code]
>
> --- In m...@yahoogroups.com, "old_cow_yellow" wrote:
> >
> > See an example in the file area.
> >
> > http://f1.grp.yahoofs.com/v1/IHiVSvT_CLCKd5JuuO2yFgKC28h3iKi_YeR6DPfztNqCs-EWNymRfGw64wrojp6kCoynPm8RUnamr28fmyXS/Member%20contributions/PWM_example.c
> >
> >
> > --- In m...@yahoogroups.com, "nsspost@" wrote:
> > >
> > > Greetings, I am sorry for bad English, I read is better than I speak. I think it is possible to use an example hardware pwm (http://www.ti.com/litv/zip/slac080e) msp430x20x3_ta_16.c . This example works with msp430f2001, msp430f2002 too, it is necessary to replace only #include on #include . CCR0 - a basis cycle, CCR1 - duty a cycle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from TI.COM) :
> > >
> > > #include
> > >
> > > void main(void)
> > > {
> > > 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
> > > CCR1 = 384; // CCR1 PWM duty cycle
> > > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> > >
> > > // _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory at debugging
> > >
> > > while(1){
> > > CCR0=10000;
> > > CCR1=1000; // 10000/1000= pwm 10%
> > > //CCR1=5000; // pwm 50%
> > >
> > > }
> > >
> > > }
> > >
> > >
> > > If necessary it is possible to add interrupt service routine.
> > > pwm all time while works Timer_A, values CCR0 works and CCR1 vary at any moment, when necessary.
> > >
>

------------------------------------



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

Re: how to genearate varibale PWM - old_cow_yellow - Aug 31 11:14:01 2009

If you have an oscilloscope, use it to watch P1.2. Do not use the debugger.

--- In m...@yahoogroups.com, "madh_86" wrote:
>
> When i have debugged the given program i am not getting the varibale PWM output once the timer has started after overflow it is not going into ISR and updating the CCR1 value please suggest me the solution.I want variable pwm like in first period 10% and second period 20% dutycycle like this so on...kindly help me out....
>
> thanks in advance
>
> #include // ***OCY***
>
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> P1DIR |= 0x04; // P1.2 output ***OCY***
> P1SEL |= 0x04; // P1.2 TA1-out ***OCY***
> CCR0 = 512-1; // PWM Period
> CCTL0 = CCIE; // ***OCY***
> CCTL1 = OUTMOD_7; // CCR1 reset/set
> CCR1 = 384; // CCR1 PWM duty cycle
> TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
>
> _BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
> }
>
> // All lines below are added by ***OCY***
> #pragma vector=TIMERA0_ VECTOR
> __interrupt void Timer_A (void)
> {
> CCR1++; // Increse duty cycle
> if (CCR1 > CCR0) CCR1 = 51; // If too big, change to very small
> }
> [\code]
> --- In m...@yahoogroups.com, "old_cow_yellow" wrote:
> >
> > [code]
> > //******************************************************************************
> > // MSP430F20xx Demo - Timer_A, PWM TA1-2, Up Mode, DCO SMCLK
> > //
> > // Description: This program generates one PWM output on P1.2 using
> > // Timer_A configured for up mode. The value in CCR0, 512-1, defines the PWM
> > // period and the value in CCR1 the PWM duty cycles.
> > // A 75% duty cycle on P1.2.
> > // ACLK = na, SMCLK = MCLK = TACLK = default DCO
> > //
> > // MSP430F20xx
> > // -----------------
> > // /|\| XIN|-
> > // | | |
> > // --|RST XOUT|-
> > // | |
> > // | P1.2/TA1|--> CCR1 - 75% PWM
> > //
> > // M.Buccini / L. Westlund
> > // Texas Instruments, Inc
> > // October 2005
> > // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
> > //
> > // Modified but untested - by Old_Cow_Yellow
> > //******************************************************************************
> >
> > #include // ***OCY***
> >
> > void main(void)
> > {
> > WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> > P1DIR |= 0x04; // P1.2 output ***OCY***
> > P1SEL |= 0x04; // P1.2 TA1-out ***OCY***
> > CCR0 = 512-1; // PWM Period
> > CCTL0 = CCIE; // ***OCY***
> > CCTL1 = OUTMOD_7; // CCR1 reset/set
> > CCR1 = 384; // CCR1 PWM duty cycle
> > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> >
> > _BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
> > }
> >
> > // All lines below are added by ***OCY***
> > #pragma vector=TIMERA0_VECTOR
> > __interrupt void Timer_A (void)
> > {
> > CCR1++; // Increse duty cycle
> > if (CCR1 > CCR0) CCR1 = 51; // If too big, change to very small
> > }
> > [\code]
> >
> > --- In m...@yahoogroups.com, "old_cow_yellow" wrote:
> > >
> > > See an example in the file area.
> > >
> > > http://f1.grp.yahoofs.com/v1/IHiVSvT_CLCKd5JuuO2yFgKC28h3iKi_YeR6DPfztNqCs-EWNymRfGw64wrojp6kCoynPm8RUnamr28fmyXS/Member%20contributions/PWM_example.c
> > >
> > >
> > > --- In m...@yahoogroups.com, "nsspost@" wrote:
> > > >
> > > > Greetings, I am sorry for bad English, I read is better than I speak. I think it is possible to use an example hardware pwm (http://www.ti.com/litv/zip/slac080e) msp430x20x3_ta_16.c . This example works with msp430f2001, msp430f2002 too, it is necessary to replace only #include on #include . CCR0 - a basis cycle, CCR1 - duty a cycle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from TI.COM) :
> > > >
> > > > #include
> > > >
> > > > void main(void)
> > > > {
> > > > 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
> > > > CCR1 = 384; // CCR1 PWM duty cycle
> > > > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> > > >
> > > > // _BIS_SR(CPUOFF); // Enter LPM0 It is not obligatory at debugging
> > > >
> > > > while(1){
> > > > CCR0=10000;
> > > > CCR1=1000; // 10000/1000= pwm 10%
> > > > //CCR1=5000; // pwm 50%
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > > If necessary it is possible to add interrupt service routine.
> > > > pwm all time while works Timer_A, values CCR0 works and CCR1 vary at any moment, when necessary.
> > > >
> > >
>

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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

Re: Re: how to genearate varibale PWM - yamsani madhu sudhan - Aug 31 23:04:00 2009

I am checking with oscilloscope only...when i am using the given below code=
removing the comments for second CCR1 in while loop i am able to get varia=
ble pulses of fixed timeperiod for few pulses and different timeperiod and =
duty cycle for another pulse so cyclic reptancy of the pulses is also not t=
he same....kindly help out in this logic such that i can get variable duty =
cycle in each succesive cycle and time period being constant...
=A0
thanks in advance....
=A0
#include
> > > >=20
> > > > void main(void)
> > > > {
> > > > WDTCTL =3D WDTPW + WDTHOLD; // Stop WDT
> > > > P1DIR |=3D 0x0C; // P1.2 and P1.3 output
> > > > P1SEL |=3D 0x0C; // P1.2 and P1.3 TA1/2 options
> > > > CCR0 =3D 512-1; // PWM Period
> > > > CCTL1 =3D OUTMOD_7; // CCR1 reset/set
> > > > CCR1 =3D 384; // CCR1 PWM duty cycle
> > > > TACTL =3D TASSEL_2 + MC_1; // SMCLK, up mode
> > > >=20
> > > > // _BIS_SR(CPUOFF) ; // Enter LPM0 It is not obligatory at debuggin=
g
> > > >=20
> > > > while(1){
> > > > CCR0=3D10000;=20
> > > > CCR1=3D1000; // 10000/1000=3D pwm 10%=20
> > > > //CCR1=3D5000; // pwm 50%=20
> > > >=20
> > > > }
> > > >=20
> > > > }

=A0
=A0
=A0
=A0

--- On Mon, 31/8/09, old_cow_yellow wrote:
From: old_cow_yellow
Subject: [msp430] Re: how to genearate varibale PWM
To: m...@yahoogroups.com
Date: Monday, 31 August, 2009, 8:42 PM
=A0=20

If you have an oscilloscope, use it to watch P1.2. Do not use the debugger.

--- In msp430@yahoogroups. com, "madh_86" wrote:
>
> When i have debugged the given program i am not getting the varibale PWM =
output once the timer has started after overflow it is not going into ISR a=
nd updating the CCR1 value please suggest me the solution.I want variable p=
wm like in first period 10% and second period 20% dutycycle like this so on=
...kindly help me out....
>=20
> thanks in advance
>=20
> #include // ***OCY***
>=20
> void main(void)
> {
> WDTCTL =3D WDTPW + WDTHOLD; // Stop WDT
> P1DIR |=3D 0x04; // P1.2 output ***OCY***
> P1SEL |=3D 0x04; // P1.2 TA1-out ***OCY***
> CCR0 =3D 512-1; // PWM Period
> CCTL0 =3D CCIE; // ***OCY***
> CCTL1 =3D OUTMOD_7; // CCR1 reset/set
> CCR1 =3D 384; // CCR1 PWM duty cycle
> TACTL =3D TASSEL_2 + MC_1; // SMCLK, up mode
>=20
> _BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
> }
>=20
> // All lines below are added by ***OCY***
> #pragma vector=3DTIMERA0_ VECTOR
> __interrupt void Timer_A (void)
> {
> CCR1++; // Increse duty cycle
> if (CCR1 > CCR0) CCR1 =3D 51; // If too big, change to very small
> }
> [\code]
>=20
>=20
>=20
>=20
> --- In msp430@yahoogroups. com, "old_cow_yellow" wrote=
:
> >
> > [code]
> > //********** ********* ********* ********* ********* ********* ********=
* ********* *****
> > // MSP430F20xx Demo - Timer_A, PWM TA1-2, Up Mode, DCO SMCLK
> > //
> > // Description: This program generates one PWM output on P1.2 using
> > // Timer_A configured for up mode. The value in CCR0, 512-1, defines th=
e PWM
> > // period and the value in CCR1 the PWM duty cycles.
> > // A 75% duty cycle on P1.2.
> > // ACLK =3D na, SMCLK =3D MCLK =3D TACLK =3D default DCO
> > //
> > // MSP430F20xx
> > // ------------ -----
> > // /|\| XIN|-
> > // | | |
> > // --|RST XOUT|-
> > // | |
> > // | P1.2/TA1|--> CCR1 - 75% PWM
> > //
> > // M.Buccini / L. Westlund
> > // Texas Instruments, Inc
> > // October 2005
> > // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.=
40A
> > //
> > // Modified but untested - by Old_Cow_Yellow
> > //********** ********* ********* ********* ********* ********* ********=
* ********* *****
> >=20
> > #include // ***OCY***
> >=20
> > void main(void)
> > {
> > WDTCTL =3D WDTPW + WDTHOLD; // Stop WDT
> > P1DIR |=3D 0x04; // P1.2 output ***OCY***
> > P1SEL |=3D 0x04; // P1.2 TA1-out ***OCY***
> > CCR0 =3D 512-1; // PWM Period
> > CCTL0 =3D CCIE; // ***OCY***
> > CCTL1 =3D OUTMOD_7; // CCR1 reset/set
> > CCR1 =3D 384; // CCR1 PWM duty cycle
> > TACTL =3D TASSEL_2 + MC_1; // SMCLK, up mode
> >=20
> > _BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
> > }
> >=20
> > // All lines below are added by ***OCY***
> > #pragma vector=3DTIMERA0_ VECTOR
> > __interrupt void Timer_A (void)
> > {
> > CCR1++; // Increse duty cycle
> > if (CCR1 > CCR0) CCR1 =3D 51; // If too big, change to very small
> > }
> > [\code]
> >=20
> > --- In msp430@yahoogroups. com, "old_cow_yellow" wro=
te:
> > >
> > > See an example in the file area.
> > >=20
> > > http://f1.grp. yahoofs.com/ v1/IHiVSvT_ CLCKd5JuuO2yFgKC 28h3iKi_YeR6=
DPfz tNqCs-EWNymRfGw6 4wrojp6kCoynPm8R Unamr28fmyXS/ Member%20contrib ution=
s/PWM_ example.c
> > >=20
> > >=20
> > > --- In msp430@yahoogroups. com, "nsspost@" wrote:
> > > >
> > > > Greetings, I am sorry for bad English, I read is better than I spea=
k. I think it is possible to use an example hardware pwm (http://www.ti. co=
m/litv/ zip/slac080e) msp430x20x3_ ta_16.c . This example works with msp430=
f2001, msp430f2002 too, it is necessary to replace only #include x3. h> on #include . CCR0 - a basis cycle, CCR1 - duty a cy=
cle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from T=
I.COM) :
> > > >=20
> > > > #include
> > > >=20
> > > > void main(void)
> > > > {
> > > > WDTCTL =3D WDTPW + WDTHOLD; // Stop WDT
> > > > P1DIR |=3D 0x0C; // P1.2 and P1.3 output
> > > > P1SEL |=3D 0x0C; // P1.2 and P1.3 TA1/2 options
> > > > CCR0 =3D 512-1; // PWM Period
> > > > CCTL1 =3D OUTMOD_7; // CCR1 reset/set
> > > > CCR1 =3D 384; // CCR1 PWM duty cycle
> > > > TACTL =3D TASSEL_2 + MC_1; // SMCLK, up mode
> > > >=20
> > > > // _BIS_SR(CPUOFF) ; // Enter LPM0 It is not obligatory at debuggin=
g
> > > >=20
> > > > while(1){
> > > > CCR0=3D10000;=20
> > > > CCR1=3D1000; // 10000/1000=3D pwm 10%=20
> > > > //CCR1=3D5000; // pwm 50%=20
> > > >=20
> > > > }
> > > >=20
> > > > }
> > > >=20
> > > >=20
> > > > If necessary it is possible to add interrupt service routine.
> > > > pwm all time while works Timer_A, values CCR0 works and CCR1 vary a=
t any moment, when necessary.
> > > >
> > >
>
See the Web's breaking stories, chosen by people like you. Check =
out Yahoo! Buzz. http://in.buzz.yahoo.com/

[Non-text portions of this message have been removed]

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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

Re: how to genearate varibale PWM - old_cow_yellow - Aug 31 23:51:57 2009

#include // ***OCY***

void main(void)
{
WDTCTL =3D WDTPW + WDTHOLD; // Stop WDT
P1DIR |=3D 0x04; // P1.2 output ***OCY***
P1SEL |=3D 0x04; // P1.2 TA1-out ***OCY***
CCR0 =3D 512-1; // PWM Period
CCTL0 =3D CCIE; // ***OCY***
CCTL1 =3D OUTMOD_7; // CCR1 reset/set
CCR1 =3D 384; // CCR1 PWM duty cycle
TACTL =3D TASSEL_2 + MC_1; // SMCLK, up mode

_BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
}

// All lines below are added by ***OCY***
#pragma vector=3DTIMERA0_VECTOR
__interrupt void Timer_A (void)
{
CCR1 +=3D 51; // Increse duty cycle



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

Re: Re: how to genearate varibale PWM - Microbit_Ubuntu - Sep 1 2:57:01 2009

Hi,

On Tue, 2009-09-01 at 08:23 +0530, yamsani madhu sudhan wrote:
> I am checking with oscilloscope only...when i am using the given below code removing the comments for second CCR1 in while loop i am able to get variable pulses of fixed timeperiod for few pulses and different timeperiod and duty cycle for another pulse so cyclic reptancy of the pulses is also not the same....kindly help out in this logic such that i can get variable duty cycle in each succesive cycle and time period being constant...
>
> thanks in advance....
>
> #include
> > > > >
> > > > > void main(void)
> > > > > {
> > > > > 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
> > > > > CCR1 = 384; // CCR1 PWM duty cycle
> > > > > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> > > > >
> > > > > // _BIS_SR(CPUOFF) ; // Enter LPM0 It is not obligatory at debugging
> > > > >
> > > > > while(1){
> > > > > CCR0=10000;
> > > > > CCR1=1000; // 10000/1000= pwm 10%
> > > > > //CCR1=5000; // pwm 50%
> > > > >
> > > > > }
> > > > >
> > > > > }
>
>
>
>
>
>
> --- On Mon, 31/8/09, old_cow_yellow wrote:
> From: old_cow_yellow
> Subject: [msp430] Re: how to genearate varibale PWM
> To: m...@yahoogroups.com
> Date: Monday, 31 August, 2009, 8:42 PM
>
>
> If you have an oscilloscope, use it to watch P1.2. Do not use the debugger.
>
> --- In msp430@yahoogroups. com, "madh_86" wrote:
> >
> > When i have debugged the given program i am not getting the varibale PWM output once the timer has started after overflow it is not going into ISR and updating the CCR1 value please suggest me the solution.I want variable pwm like in first period 10% and second period 20% dutycycle like this so on...kindly help me out....
> >
> > thanks in advance
> >
> > #include // ***OCY***
> >
> > void main(void)
> > {
> > WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> > P1DIR |= 0x04; // P1.2 output ***OCY***
> > P1SEL |= 0x04; // P1.2 TA1-out ***OCY***
> > CCR0 = 512-1; // PWM Period
> > CCTL0 = CCIE; // ***OCY***
> > CCTL1 = OUTMOD_7; // CCR1 reset/set
> > CCR1 = 384; // CCR1 PWM duty cycle
> > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> >
> > _BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
> > }
> >
> > // All lines below are added by ***OCY***
> > #pragma vector=TIMERA0_ VECTOR
> > __interrupt void Timer_A (void)
> > {
> > CCR1++; // Increse duty cycle
> > if (CCR1 > CCR0) CCR1 = 51; // If too big, change to very small
> > }
> > [\code]
> >
> >
> >
> >
> > --- In msp430@yahoogroups. com, "old_cow_yellow" wrote:
> > >
> > > [code]
> > > //********** ********* ********* ********* ********* ********* ********* ********* *****
> > > // MSP430F20xx Demo - Timer_A, PWM TA1-2, Up Mode, DCO SMCLK
> > > //
> > > // Description: This program generates one PWM output on P1.2 using
> > > // Timer_A configured for up mode. The value in CCR0, 512-1, defines the PWM
> > > // period and the value in CCR1 the PWM duty cycles.
> > > // A 75% duty cycle on P1.2.
> > > // ACLK = na, SMCLK = MCLK = TACLK = default DCO
> > > //
> > > // MSP430F20xx
> > > // ------------ -----
> > > // /|\| XIN|-
> > > // | | |
> > > // --|RST XOUT|-
> > > // | |
> > > // | P1.2/TA1|--> CCR1 - 75% PWM
> > > //
> > > // M.Buccini / L. Westlund
> > > // Texas Instruments, Inc
> > > // October 2005
> > > // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
> > > //
> > > // Modified but untested - by Old_Cow_Yellow
> > > //********** ********* ********* ********* ********* ********* ********* ********* *****
> > >
> > > #include // ***OCY***
> > >
> > > void main(void)
> > > {
> > > WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> > > P1DIR |= 0x04; // P1.2 output ***OCY***
> > > P1SEL |= 0x04; // P1.2 TA1-out ***OCY***
> > > CCR0 = 512-1; // PWM Period
> > > CCTL0 = CCIE; // ***OCY***
> > > CCTL1 = OUTMOD_7; // CCR1 reset/set
> > > CCR1 = 384; // CCR1 PWM duty cycle
> > > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> > >
> > > _BIS_SR(CPUOFF | GIE); // Enter LPM0 ***OCY***
> > > }
> > >
> > > // All lines below are added by ***OCY***
> > > #pragma vector=TIMERA0_ VECTOR
> > > __interrupt void Timer_A (void)
> > > {
> > > CCR1++; // Increse duty cycle
> > > if (CCR1 > CCR0) CCR1 = 51; // If too big, change to very small
> > > }
> > > [\code]
> > >
> > > --- In msp430@yahoogroups. com, "old_cow_yellow" wrote:
> > > >
> > > > See an example in the file area.
> > > >
> > > > http://f1.grp. yahoofs.com/ v1/IHiVSvT_ CLCKd5JuuO2yFgKC 28h3iKi_YeR6DPfz tNqCs-EWNymRfGw6 4wrojp6kCoynPm8R Unamr28fmyXS/ Member%20contrib utions/PWM_ example.c
> > > >
> > > >
> > > > --- In msp430@yahoogroups. com, "nsspost@" wrote:
> > > > >
> > > > > Greetings, I am sorry for bad English, I read is better than I speak. I think it is possible to use an example hardware pwm (http://www.ti. com/litv/ zip/slac080e) msp430x20x3_ ta_16.c . This example works with msp430f2001, msp430f2002 too, it is necessary to replace only #include on #include . CCR0 - a basis cycle, CCR1 - duty a cycle. Values CCR0 and CCR1 can be changed from main {}. Source codes (from TI.COM) :
> > > > >
> > > > > #include
> > > > >
> > > > > void main(void)
> > > > > {
> > > > > 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
> > > > > CCR1 = 384; // CCR1 PWM duty cycle
> > > > > TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
> > > > >
> > > > > // _BIS_SR(CPUOFF) ; // Enter LPM0 It is not obligatory at debugging
> > > > >
> > > > > while(1){
> > > > > CCR0=10000;
> > > > > CCR1=1000; // 10000/1000= pwm 10%
> > > > > //CCR1=5000; // pwm 50%
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > >
> > > > > If necessary it is possible to add interrupt service routine.
> > > > > pwm all time while works Timer_A, values CCR0 works and CCR1 vary at any moment, when necessary.
> > > > >
> > > >
> > >
> > See the Web's breaking stories, chosen by people like you. Check out Yahoo! Buzz. http://in.buzz.yahoo.com/
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


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

Re: Re: how to genearate varibale PWM - yamsani madhu sudhan - Sep 9 0:18:39 2009

Hi,
=A0=A0=A0=A0=A0=A0 Now i am able to genearate variable pwm with the code be=
low,now what=A0 my requirement is i have to linearly increment duty cycle b=
y 12% upto duty cycle of max 60% and from there i have have to linearly dec=
rease to 12% ,i am able to linearly increase upto 60% duty cycle but i am u=
anble to linearly decrease from there if i am using conditon loops also i a=
m unable to get variable pwm.pls help me out in the logic for linearly decr=
easing duty cycle after linearly increasing =A0
thanks in advance....

#include =20
unsigned int count=3D0;
unsigned int i=3D305;
void main(void)
{
WDTCTL =3D WDTPW + WDTHOLD; // Stop WDT
P1DIR |=3D 0x04; // P1.2 output=20
P1SEL |=3D 0x04; // P1.2 TA1-out=20
CCR0 =3D 512-1; // PWM Period
CCTL0 =3D CCIE; //=20
CCTL1 =3D OUTMOD_7; // CCR1 reset/set
CCR1 =3D 61; // CCR1 PWM duty cycle
TACTL =3D TASSEL_2 + MC_1; // SMCLK, up mode
_EINT();
for (;;)
{
_BIS_SR(CPUOFF); // Enter LPM0
_NOP(); // Required only for C-spy
}
}
#pragma vector=3DTIMERA0_VECTOR
__interrupt void Timer_A (void)
{
CCR1 +=3D 61; // Increse duty cycle



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