This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
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
}
Hi,
I have never used this board, but after a quick checking of the datasheet, I have seen that TA1.0 can use P2.0 and P2.3. So in TA1CTTL1 you may set the the input that you will use, in this case CCI0A. Check the header file to know how mnemonic you can use.
I hope it helps you.
Yes I see that. I tried with this line TA1CCTL1 = OUTMOD_7 + CCIS_0; and it didn't work. I still cant get a PWM output on P2.0.
Hi again,
I have checked the datasheet of your uC. Port 2.0 is showed like "P2.0/TA1.0". It means that the control register for this pin is TA1CCTL0 instead of TA1CCTL1, that is to say, you are selecting P2.0 to work as an output for PWM, but you are configuring the parameter of the PWM for P2.1. Try changing TA1CCTL1 by TA1CCTL0
I hope it helps you.
Yes, you found it. TA1.1 output is on P2.1.Is T da S said:Port 2.0 is showed like "P2.0/TA1.0"
Won't work. If using CCR0 for PWM output, the tiemr must run in cont mode and PWM cycle time is 65536 tiemr ticks. Or you will (dpendign on OUTMOD settign) either get a shot (one timer tick) pulse on the output or a signal with half frequency and 50% DC.Is T da S said:Try changing TA1CCTL1 by TA1CCTL0
Yes thank you. I understand now. I'm using P2.1 and P2.2 for my servos now.
Got it working correctly.
**Attention** This is a public forum