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.

MSP432P401R: PWM output

Part Number: MSP432P401R

I am trying to output a pwm signal with a period of 20ms and a duty cycle of 2 ms to make a servo motor spin. It is not working at all.  I am assuming that the SMCLK frequency is 12 MHz, although I may be wrong. I was also wondering why the line #define TIMER_A_CLOCKSOURCE_DIVIDER_1 0x78 was throwing an error. Thanks so much!

 

#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
#define TIMER_A_CLOCKSOURCE_DIVIDER_1 0x78

 Timer_A_PWMConfig pwmConfig =
    {
     TIMER_A_CLOCKSOURCE_SMCLK,
     TIMER_A_CLOCKSOURCE_DIVIDER_1,
     2000,
     TIMER_A_CAPTURECOMPARE_REGISTER_0,
     TIMER_A_OUTPUTMODE_RESET_SET,
     20
    };

int main(void)
{

    /* Stop Watchdog  */
    MAP_WDT_A_holdTimer();
    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
    Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig);

    while(1)
    {
        
    }

  • >TIMER_A_CAPTURECOMPARE_REGISTER_0,

    P2.4 is TA0.1, so this should be:

    >TIMER_A_CAPTURECOMPARE_REGISTER_1,

    ------------

    >     2000,

    [...]

    >     20

    Since you haven't changed it, SMCLK=3MHz. So the period should be (20000 usec * 3 ticks/usec)=60000, and the duty should be (2000 usec * 3 ticks/usec) = 6000.

    ------------

    What is your purpose in trying to re-define TIMER_A_CLOCKSOURCE_DIVIDER_1? You already get this symbol from <driverlib.h>

  • This worked, Thank you!