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.

MSP-EXP432P401R PWM example, add external leds to p3.6 and p3.7

Other Parts Discussed in Thread: ENERGIA

Hello all,

I have added two external leds to port 3 pin 6 and 7, but cannot seem to get the code to work, I hve tried with Energia and the circuit is ok,

as for code,

I modified to MSP_EXP432P401R.h:

typedef enum MSP_EXP432P401R_GPIOName {
    MSP_EXP432P401R_S1 = 0,
    MSP_EXP432P401R_S2,
    MSP_EXP432P401R_LED1,
    MSP_EXP432P401R_LED_RED,

    /*
     * MSP_EXP432P401R_LED_GREEN & MSP_EXP432P401R_LED_BLUE are used for
     * PWM examples.  Uncomment the following lines if you would like to control
     * the LEDs with the GPIO driver.
     */
    MSP_EXP432P401R_LED_GREEN,
    MSP_EXP432P401R_LED_BLUE,

	KB_LED_0,
	KB_LED_1,

    MSP_EXP432P401R_GPIOCOUNT
} MSP_EXP432P401R_GPIOName;

......

typedef enum MSP_EXP432P401R_PWMName {
    MSP_EXP432P401R_PWM_TA1_1 = 0,
    MSP_EXP432P401R_PWM_TA1_2,
	MSP_EXP432P401R_PWM_TA1_3,
	MSP_EXP432P401R_PWM_TA1_4,
    MSP_EXP432P401R_PWMCOUNT
} MSP_EXP432P401R_PWMName;

and MSP_EXP432P401R.c:

GPIO_PinConfig gpioPinConfigs[] = {
    /* Input pins */
    /* MSP_EXP432P401R_S1 */
    GPIOMSP432_P1_1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
    /* MSP_EXP432P401R_S2 */
    GPIOMSP432_P1_4 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,

    /* Output pins */
    /* MSP_EXP432P401R_LED1 */
    GPIOMSP432_P1_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* MSP_EXP432P401R_LED_RED */
    GPIOMSP432_P2_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,

    /*
     * MSP_EXP432P401R_LED_GREEN & MSP_EXP432P401R_LED_BLUE are used for
     * PWM examples.  Uncomment the following lines if you would like to control
     * the LEDs with the GPIO driver.
     */
    /* MSP_EXP432P401R_LED_GREEN */
    GPIOMSP432_P2_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* MSP_EXP432P401R_LED_BLUE */
    GPIOMSP432_P2_2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* KB_LED_0 */
    GPIOMSP432_P3_6 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* KB_LED_1 */
    GPIOMSP432_P3_7 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,

	
};

...

const PWMTimerMSP432_HWAttrsV1 pwmTimerMSP432HWAttrs[MSP_EXP432P401R_PWMCOUNT] = {
    {
        .timerBaseAddr = TIMER_A1_BASE,
        .clockSource = TIMER_A_CLOCKSOURCE_SMCLK,
        .compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1,
        .gpioPort = GPIO_PORT_P2,
        .gpioPinIndex = GPIO_PIN1,
        .pwmMode = GPIO_PRIMARY_MODULE_FUNCTION
    },
    {
        .timerBaseAddr = TIMER_A1_BASE,
        .clockSource = TIMER_A_CLOCKSOURCE_SMCLK,
        .compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_2,
        .gpioPort = GPIO_PORT_P2,
        .gpioPinIndex = GPIO_PIN2,
        .pwmMode = GPIO_PRIMARY_MODULE_FUNCTION
    },
    {
        .timerBaseAddr = TIMER_A1_BASE,
        .clockSource = TIMER_A_CLOCKSOURCE_SMCLK,
        .compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_3,
        .gpioPort = GPIO_PORT_P3,
        .gpioPinIndex = GPIO_PIN6,
        .pwmMode = GPIO_PRIMARY_MODULE_FUNCTION
    },
    {
        .timerBaseAddr = TIMER_A1_BASE,
        .clockSource = TIMER_A_CLOCKSOURCE_SMCLK,
        .compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_3,
        .gpioPort = GPIO_PORT_P3,
        .gpioPinIndex = GPIO_PIN7,
        .pwmMode = GPIO_PRIMARY_MODULE_FUNCTION
    }
};

const PWM_Config PWM_config[] = {
    {
        .fxnTablePtr = &PWMTimerMSP432_fxnTable,
        .object = &pwmTimerMSP432Objects[0],
        .hwAttrs = &pwmTimerMSP432HWAttrs[0]
    },
    {
        .fxnTablePtr = &PWMTimerMSP432_fxnTable,
        .object = &pwmTimerMSP432Objects[1],
        .hwAttrs = &pwmTimerMSP432HWAttrs[1]
    },
    {
        .fxnTablePtr = &PWMTimerMSP432_fxnTable,
        .object = &pwmTimerMSP432Objects[2],
        .hwAttrs = &pwmTimerMSP432HWAttrs[2]
    },
	{
		.fxnTablePtr = &PWMTimerMSP432_fxnTable,
		.object = &pwmTimerMSP432Objects[3],
		.hwAttrs = &pwmTimerMSP432HWAttrs[3]
	},
    {NULL, NULL, NULL}
};

/*
 *  ======== MSP_EXP432P401R_initPWM ========
 */
void MSP_EXP432P401R_initPWM(void)
{
    /* Use Port Map on Port2 get Timer outputs on pins with LEDs (2.1, 2.2) */
    const uint8_t portMap_port2 [] = {
        PM_NONE, PM_TA1CCR1A, PM_TA1CCR2A, PM_NONE,
        PM_NONE, PM_NONE,     PM_NONE,     PM_NONE
    };

    /* Mapping capture compare registers to Port 2 */
	MAP_PMAP_configurePorts((const uint8_t *) portMap_port2, PMAP_P2MAP, 1,
		PMAP_DISABLE_RECONFIGURATION);

    const uint8_t portMap_port3 [] = {
		PM_NONE, PM_NONE, PM_NONE, PM_NONE,
		PM_NONE, PM_NONE, PM_TA1CCR3A, PM_TA1CCR4A
	};

    /* Mapping capture compare registers to Port 3 */
	MAP_PMAP_configurePorts((const uint8_t *) portMap_port3, PMAP_P3MAP, 1,
		PMAP_DISABLE_RECONFIGURATION);

    PWM_init();
}

and as for the main c code, it's the same as the xample except I changed

pwm1 = PWM_open(Board_PWM2, &params); to pwm1 = PWM_open(MSP_EXP432P401R_PWM_TA1_3, &params);

what m I missing? any ideas?

Many thanks