Jump to content


  • Content Count

  • Joined

  • Last visited

  1. It worked! It's a common mistake i wonder how i miss it. Anyway, thanks RobG! Erdem
  2. Hi all, I am trying to control a common rc servo with launchpad. I am using timer for pwm signals. But my code doesn't work. I am stuck. Basic codes from ti tutorials don't work either. My servo is : SM-s3317s I power it with arduino uno (5V and GND) also connect the control wire to launchpad (p1.2) . I checked the servo with arduino, it doesnt have any problem. I tried to adjust pwm period to 20 ms and also tried to have high pulses between duration of 1ms-2ms as it is seen in the code. my mcu is : g2553 Here is my code : #include <msp430g2553.h> #define SERVO_BIT BIT2 #define SM_clk 1100000 #define servo_freq 50 int i; void init() { int PWM_period = SM_clk /servo_freq; P1DIR |= SERVO_BIT; //direction is set P1SEL |= SERVO_BIT;// port 1 function is set. TA0CCR0 = PWM_period-1; // pwm period TA0CCR1 = 0; //duty cycle = TA0CCR0/ TA0CCR1 TA0CCTL1 = OUTMOD_7; } int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer init(); TA0CTL=TASSEL_2+MC_1; // starting timer by setting clock source SMCLK of timer and UP mode while(1){ TA0CCR1 = 1100; __delay_cycles(1000000); TA0CCR1 = 1300; __delay_cycles(1000000); TA0CCR1 = 1500; __delay_cycles(1000000); TA0CCR1 = 1800; __delay_cycles(1000000); TA0CCR1 = 2200; __delay_cycles(1000000); } return 0; } Does anyone have any suggestions??Is there something i did wrong?? Thanks for your time and answers!! Erdem
  • Create New...