Tool/software: Code Composer Studio
hi everyone
i have msp430g2231 chip and i want to software pwm signals for soft stop led light
i researched datasheet and internet but i cant make output pwm signal from its.
could you help me for this .
i use CCS texas program.
P1.1 , P1.2 P1.5 P1.6 P2.6 those pins are i can use pwm signal with Timer_A
#include <msp430g2231.h>
int IncDec_PWM = 1;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
DCOCTL = 0; // Select lowest DCOx and MODx
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
P1DIR |= 0x06; // P1.1 and P1.2 output
P1SEL |= 0x06; // P1.1 and P1.2 TA0./1 otions
TA0CCR0 = 1000; // PWM Period/2
TA0CCTL1 = OUTMOD_7; // CCR1 toggle/set
TA0CCR1 = 1; // CCR1 PWM duty cycle
TA0CTL = TASSEL_2 + MC_1; // ACLK, up-down mode
_BIS_SR(LPM3_bits); // Enter LPM3
#pragma vector =TIMER0_A0_VECTOR
__interrupt void TIMER_A0 (void);
{
TA0CCR1 += IncDec_PWM*2; // Increase or decrease duty cycle
if( TA0CCR1 > 998 || TA0CCR1 < 2 ) // Reverse direction if it falls within values
IncDec_PWM = -IncDec_PWM;
}