Jump to content

Recommended Posts

When programming recently, I found that I had some trouble controlling a motor at the same time as several servo. The servos would go all crazy, and the motor wouldn't work. I guessed that this was because the timers were interfering, or not enough timers, or similar. Digging into the servo library, and the analogWrite function, I found that they're both trying to use Timer A. Thus, I modified the analogWrite function.


In file energia/hardware/msp430/cores/msp430/wiring_analog.c , I commented out lines 110 to 123 (inclusive). Below is the code commented out.

			case T0A1:                              // TimerA0 / CCR1
                                TA0CCR0 = PWM_PERIOD;           // PWM Period
                                TA0CCTL1 = OUTMOD_7;            // reset/set
                                TA0CCR1 = PWM_DUTY(val);       // PWM duty cycle
                                TA0CTL = TASSEL_2 + MC_1 + analog_div;       // SMCLK, up mode
#if defined(__MSP430_HAS_TA3__) || defined(__MSP430_HAS_T0A3__) 
 			case T0A2:                              // TimerA0 / CCR2
                                TA0CCR0 = PWM_PERIOD;           // PWM Period
                                TA0CCTL2 = OUTMOD_7;            // reset/set
                                TA0CCR2 = PWM_DUTY(val);       // PWM duty cycle
                                TA0CTL = TASSEL_2 + MC_1+ analog_div;       // SMCLK, up mode

This may only work using the G2553, but if you're stuck with a G2231 from a rev 1.4 board, just sample a new chip :P

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...