Other Parts Discussed in Thread: MSP430G2553
Hello, I am trying to drive an SG90 motor via P1.7 Using TA0 timer with a PWM period of 20ms and a duty cycle of 0.35 ms and 2.35 ms. I simply want the motor to turn between 0-180 degress continuously. I followed this basic guide on YouTube: https://youtu.be/V3v5ItyMKVc and converted from msp430g2553 to msp430fr4133 accordingly. I have also connected the SG90 directly to +5V pin and GND pin and PWM signal to P1.7 pin on the board.
Attached is my code:
---------------------------------------------------------------------------------------------------------------------------------------------------------
#include <msp430.h>
#include <driverlib.h>
unsigned int TimerA0_period = 20000; // PWM Period
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// Configure Timer A0 (compare mode) and LED
// TA0CTL = TACLR; // Clear timer
// TA0R = 0; // Count of Timer_A
P1DIR |= BIT7;
P1SEL0 |= BIT7;
while(1)
{
TA0CCR0 = TimerA0_period;
TA0CCR1 = 350; // CCR1 PWM duty cycle !min 350 max 2600 angle 190, 350 2350-180 degrees
TA0CCTL1 |= OUTMOD_7; // Reset/set output mode
TA0CTL |= TASSEL_2 | MC_1; // SMCLK (1 MHz), Up mode (counts up to TA1CCR0)
__delay_cycles(1500000);
TA0CCR1 = 2350; // CCR1 PWM duty cycle !min 350 max 2600 angle 190, 350 2350-180 degrees
TA0CCTL1 |= OUTMOD_7; // Reset/set output mode
TA0CTL |= TASSEL_2 | MC_1;
__delay_cycles(1500000);
}
// __bis_SR_register(LPM0_bits); //Switch to low power mode 0.
}
---------------------------------------------------------------------------------------------------------------------------------------------------------
I think the primary difference between my code and the YouTube one is that I am missing BCSCTL1/DCOCTL calibration settings to 1 MHz, however nothing appears on the family guide for the fr4133.
During testing, nothing appears to work whenever I run the code, I attached a meter on P1.7 and the voltage does 'appear' to go up then zero then up and so but SG90 stays stationary.
Any help is greatly appreciated. Thanks!