Other Parts Discussed in Thread: MSP430G2452
Hi
I am struggling with modifying code for my project. (almost no experience with C language)
Basically what I am trying to do is to get two switching signals from two separate outputs of MSP430 G2231 (LaunchPad) using PWM.
With the script in the following, I am able to detect the switching signal (with 80% duty ratio) in oscilloscope from Pin 1.6.
How should I modify the code in order to get another inverted switching signal of Pin1.6 from Pin 1.7 (20% duty ratio in this case)?
Can somebody help me with this?
Thanks.
----------------------------------------------------------------------------------------------------------------------------------------
#include <msp430g2231.h>
#include <stdbool.h>
bool inc; // declare a boolean to determine whether to increment CCR1 or decrement it
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT6; // P1.6 output
P1SEL |= BIT6; // P1.6 TA1/2 options
CCR0 = 1000-1; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 800; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1 + TAIE; // SMCLK, up mode, Timer_A interrupt enabled, Timer_A interrupt pending
_BIS_SR(CPUOFF + GIE); // Enter LPM0 with interrupts
}
------------------------------------------------------------------------------------------------------------------------------------
