Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | MSP430 | Genearating variable 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.

Genearating variable pwm - yamsani madhu sudhan - Sep 9 22:55:52 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 )