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.
sinewave pwm for msp430f2001 - yamsani madhu sudhan - Sep 10 23:55:12 2009
Hi,i am trying to generate sine wave based pwm for every 12degrees of sine =
wave for half wave of one complete cycle i am considering it as duty cycle =
and i am trying to update CCR1 register values with the given duty cycle va=
lues ie for every 12 degree increment and i am using peak value for duty cy=
cle of 60% ie CCR1=3D305 =A0and from there i want to linearly decrease in s=
ame decrement steps.But when i debug the program i am unable to get variabl=
e pwm for sinewave is there any mistake in my logic,if so please correct me=
.
thanks in advance....
=A0
=A0#include
=20
const unsigned int duty[]=3D{122,183,244,305,244,183,122,61}
unsigned int i=3D0;
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 duty[i]; // 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)
{
for(i=3D0;i<=3D7;i++)
CCR1=3Dduty[i];
}
Yahoo! India has a new look. Take a sneak peek http://in.yahoo.com/tr=
ynew
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )
Re: sinewave pwm for msp430f2001 - old_cow_yellow - Sep 11 13:28:42 2009
--- In m...@yahoogroups.com, yamsani madhu sudhan
wrote:
>
> Hi,i am trying to generate sine wave based pwm for every 12degrees of sin=
e wave for half wave of one complete cycle i am considering it as duty cycl=
e and i am trying to update CCR1 register values with the given duty cycle =
values ie for every 12 degree increment and i am using peak value for duty =
cycle of 60% ie CCR1=3D305 =A0and from there i want to linearly decrease in=
same decrement steps.But when i debug the program i am unable to get varia=
ble pwm for sinewave is there any mistake in my logic,if so please correct =
me.
> thanks in advance....
> =A0
> =A0#include =20
> const unsigned int duty[]=3D{122,183,244,305,244,183,122,61}
> unsigned int i=3D0;
> 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 duty[i]; // 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)
> {
> for(i=3D0;i<=3D7;i++)
> CCR1=3Dduty[i];
> }
>=20
You are making the same mistake as in your previous posting.
Aug 25, MSG#42876:
=85 =85
while(1=3D=3D1)
{
if(CCR1
{
CCR1 =3D j+30; // CCR1 PWM duty cycle
}
else
{
CCR1=3D90;
}
=85 =85
It take time for the Timer to generate each PWM pulse. If you change the se=
tting before that pulse is generated, the previous setting is wiped out and=
has not effect.
BTW there are other things that do not make sense. Your duty[] does not hav=
e a sine wave at 12 degree increment. And you did not use duty[7].
------------------------------------
______________________________
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: sinewave pwm for msp430f2001 - yamsani madhu sudhan - Sep 14 2:05:35 2009
Then with out using software control how to use the code such that i will b=
e able to generate varibale pwm for sinewave.pls help me out in the logic..=
.thanks in advance
--- On Fri, 11/9/09, old_cow_yellow
wrote:
From: old_cow_yellow
Subject: [msp430] Re: sinewave pwm for msp430f2001
To: m...@yahoogroups.com
Date: Friday, 11 September, 2009, 10:58 PM
=C2=A0=20
--- In msp430@yahoogroups. com, yamsani madhu sudhan wrote:
>
> Hi,i am trying to generate sine wave based pwm for every 12degrees of sin=
e wave for half wave of one complete cycle i am considering it as duty cycl=
e and i am trying to update CCR1 register values with the given duty cycle =
values ie for every 12 degree increment and i am using peak value for duty =
cycle of 60% ie CCR1=3D305 =C2=A0and from there i want to linearly decrease=
in same decrement steps.But when i debug the program i am unable to get va=
riable pwm for sinewave is there any mistake in my logic,if so please corre=
ct me.
> thanks in advance....
> =C2=A0
> =C2=A0#include =20
> const unsigned int duty[]=3D{122, 183,244,305, 244,183,122, 61}
> unsigned int i=3D0;
> 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 duty[i]; // 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)
> {
> for(i=3D0;i<=3D7; i++)
> CCR1=3Dduty[i] ;
> }
>=20
You are making the same mistake as in your previous posting.
Aug 25, MSG#42876:
=E2=80=A6 =E2=80=A6
while(1=3D=3D1)
{
if(CCR1
{
CCR1 =3D j+30; // CCR1 PWM duty cycle
}
else
{
CCR1=3D90;
}
=E2=80=A6 =E2=80=A6
It take time for the Timer to generate each PWM pulse. If you change the se=
tting before that pulse is generated, the previous setting is wiped out and=
has not effect.
BTW there are other things that do not make sense. Your duty[] does not hav=
e a sine wave at 12 degree increment. And you did not use duty[7].
Keep up with people you care about with Yahoo! India Mail. Learn how.=
http://in.overview.mail.yahoo.com/connectmore
[Non-text portions of this message have been removed]
------------------------------------

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