Tool/software: Code Composer Studio
Hello, I am new to programming the MSP430 microcontroller.
I want 2 PWM outputs. I am restricted to a MSP430G2231 chip - and thus one timer. I have generated the PWM signal I wanted. I want to just phase shift this PWM signal and output it (so that PWM1 and PWM2 pulses DO NOT overlap). I'm not sure how to approach this. Should I load the PWM signal into some kind of buffer variable and then manipulate that variable? Perhaps apply a delay to that variable?
I put together the code below - I only get a high signal on P1.3 (PWM2 output pin).
#include <msp430.h>
int status;
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
//------Set CLOCK------------------------------------------------
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
//----------------------------------------------------------------------
//------Set PWM----------------------------------------------------
P1DIR |= BIT6; // P1.2 PWM1 output
P1SEL |= BIT6; // P1.2 as TA0.1
CCR0 = 900; // PWM Period/2
CCTL1 = OUTMOD_6; // CCR1 toggle/set
CCR1 = 850; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_3; // SMCLK, up-down mode
//------Manipulate PWM-----------------------------------------
P1DIR |= 0b00001000; // Set P1.6 as an input & P1.3 as PWM2 output
status = P1IN & BIT6; // Load PWM1 signal into status variable
if (status==1) // Looks for rising edge of PWM1 and delays 10 then outputs that same pulse
{
__delay_cycles(10);
P1OUT = status;
}
__bis_SR_register(LPM0_bits); // Enter LPM3
}
Any help would be greatly appreciated!
Thank you!