Configure MSP432 gpio pin in freeRTOS


#1

Hi,

I am new to RTOS. I edited the portableNative_MSP_EXP432P401R_freertos_gcc program in the examples according to my needs. I have written two task to blink two LED using gpio pin P2.5 and pin P3.0 in MSP432. But its very hard for me to configure the gpio. Every time I debug my it gives me the following errors,

I dont know whats wrong with my code. Here is my code,

#include <stdint.h>
#include <unistd.h>

/* RTOS header files */
#include <FreeRTOS.h>
#include <semphr.h>
#include <task.h>
#include <timers.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/I2C.h>

/* Example/Board Header files */
#include "Board.h"


void vTaskLEDA(void *p)
{
    uint32_t time = 1;
    /* Configure the LED pin */
    GPIO_init();
    for( ;; ) {
        sleep(time);
        GPIO_toggle(GPIOMSP432_P2_5);
    }
}

void vTaskLEDB(void *p)
{
    uint32_t time = 5;
    for(;;) {

        sleep(time);
        GPIO_toggle(GPIOMSP432_P3_0);
    }
}

The function vTaskLEDA and vTaskLEDB are being called in main.c file using the extern keyword. Do I need to add any header file for it to work? It has been weeks, and still, I can’t figure out the problem. I need some help guys.

Thanks in Advance.


#2

Hi,

Could you confirm GPIOMSP432_P2_5 and GPIOMSP432_P3_0 are defined in any of the header file mentioned in your program ? I think you need to show whats in the main.c file. Update this topic with the contents in the main.c file.

Regards.


#3

Hello,
I thought it would be defined in the gpio.h header file, but its not. I googled for solution, but the tutorials are confusing for me.

Contents in main.c is given below:

#include <stdint.h>
#include <unistd.h>

/* RTOS header files */
#include <FreeRTOS.h>
#include <task.h>

/* Driver header files */
#include <ti/drivers/GPIO.h>

/* Example/Board Header files */
#include "Board.h"

extern void vTaskLEDA(void *p);
extern void vTaskLEDB(void *p);


/* Stack size in 16-bit words */
#define THREADSTACKSIZE    768 / sizeof(portSTACK_TYPE)

/*
 *  ======== main ========
 */
int main(void)
{

    Board_initGeneral();

    xTaskCreate((TaskFunction_t)vTaskLEDA, "LEDA", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
    xTaskCreate((TaskFunction_t)vTaskLEDB, "LEDB", configMINIMAL_STACK_SIZE, NULL, 2, NULL);

    GPIO_init();
    vTaskStartScheduler();

    return (0);
}

//*****************************************************************************
//
//! \brief Application defined malloc failed hook
//!
//! \param  none
//!
//! \return none
//!
//*****************************************************************************
void vApplicationMallocFailedHook()
{
    /* Handle Memory Allocation Errors */
    while(1)
    {
    }
}

//*****************************************************************************
//
//! \brief Application defined stack overflow hook
//!
//! \param  none
//!
//! \return none
//!
//*****************************************************************************
void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName)
{
    //Handle FreeRTOS Stack Overflow
    while(1)
    {
    }
}

#4

In order to configure gpio pins, you need to edit MSP_EXP432P401R.c, MSP_EXP432P401R.h, Board.h files in the project folder. For example, if you want to make work pin P2_5 of msp432, then go to MSP_EXP432P401R.c and add

GPIOMSP432_P2_5 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_LOW | GPIO_CFG_OUT_LOW,

in GPIO_PinConfig gpioPinConfigs array. After that go to MSP_EXP432P401R.h and add a name MSP_EXP432P401R_CUS_P2_5 ( you may choose whatever name you want ) in MSP_EXP432P401R_GPIOName enum declaration. Note that the order of the pin configurations must coincide with what was defined in MSP_EXP432P401R.h. Finally go to Board.h and add

  #define board_GPIO_P2_5  MSP_EXP432P401R_CUS_P2_5

You may choose any name instead of board_GPIO_P2_5. Now everything is done and you may use Board_GPIO_P2_5 to tweak pin P2_5 of MSP432.

  • Go to MSP_EXP432P401R.c

part1

  • Go to MSP_EXP432P401R.h

part2

  • Go to Board.h

part3

  • Finally pin ready to use

part4

Regards!!


#5

i did the same but my program is not working


#6

Hi. I think its better, you create a new topic with details like output error, code snippets and a very brief explanation of what you are trying to achieve. It will help members to understand your issues faster and help you with remedies.You may add the link of this topic in your new topic to point out the problem.