Hello,
I'm trying to configure PWM output to drive two servo motors. I can get one side to work but not the other. Not sure what's going on. Maybe my settings are not correct. But the Idea is to have the signal for the sesrvos going out on P2.0 and P2.1 of the MSP-EXP430G2 with the MSP430G2553. My DCO is configured for 8MHZ and the SMCLK to 1MHZ. So the input clock for the timer is SMCLK / 4 to give me 250KHz clock input to the timer.
So for the serco I have the period set for 50Hz/20ms and pulse width to about 2ms. As the code is below I can only get it to work on P1.6 and not P2.0. This is just for testing, but idealy I would like to use P2.0 and P2.1 for the signal to the servos. Any help will be appreciated.
#include <msp430g2553.h>
void main(void){
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
BCSCTL1 = CALBC1_8MHZ; //Set DCO Range, ACLK DIV/1, XTS Low-frequency mode.
DCOCTL = CALDCO_8MHZ; //Set DCO Step and Modulation
BCSCTL3 |= LFXT1S_0 + XCAP_3; //LFXT1 = 32768-Hz crystal on LFXT1, ~12.5 pF
BCSCTL2 |= SELM_0 + DIVM_0 + DIVS_3; //MCLK = DCO, SMCLK = MCLK/8
P1DIR |= BIT6;
P2DIR |= BIT0;
P1SEL |= BIT6;
P2SEL |= BIT0;
TA0CCR0 = 5000;
TA1CCR0 = 5000;
TA0CCR1 = 500;
TA1CCR1 = 500;
TA0CCTL1 = OUTMOD_7;
TA1CCTL1 = OUTMOD_7;
TA1CTL = TASSEL_2 + MC_1 + ID_2;
TA0CTL = TASSEL_2 + MC_1 + ID_2;
_BIS_SR(LPM0_bits); // Enter Low power mode 0
}