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.

CCS/MSP432P401R: POSIX Project Zero in SimpleLink Academy

Part Number: MSP432P401R
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Code Composer Studio

Hi,

I am using MSP-EXP432P401R with CCS 9.1.0 and simplelink_msp432p4_sdk_3_20_00_06.

Recently I followed the "POSIX Project Zero" under "SimpleLink Academy > Real-Time OS" in TI Resource Explorer, got it through and found all works fine.

So I tried changing POSIX threads with RTOS Tasks, leaving mqueue APIs' as it is.

To support RTOS Task and mqueue in RTOS, I did it through 2 steps:

Step-1:

    Modify main_tirtos.c to change POSIX threads with RTOS Tasks and comment out mq_send() in uartecho.c

Step-2:

   Modify main_tirtos.c, uartecho.c and alarm.c to pass mqueue handle among them.

Step-1 was finished without any problem and runs well.

But, in Step-2 uartecho.c halted when I hit ‘X’. When I debug these programs with CCS, I find uartecho.c stopped at the point of mq_send() api call.

Following screen shot shows program halted when ‘X’ is pressed.

Following shows debugging screen that I got when hit “Suspend” debugging button when uartecho.c halted.

Could you kindly advise me what is the real problem in here ?

 

Also attached source programs for your reference:

************    main_tirtos.c  **********************************

/*
 *  ======== main_tirtos.c ========
 *  TI Resource Explorer
 *  /Software/SimpleLink MSP432P4 SDK/SimpleLink Academy/Real-Time OS/POSIX Project Zero/
 *  /Software/SimpleLink MSP432P4 SDK/Examples/Development Tools/[LaunchPad]/TI Drivers/uartecho/TI-RTOS/CCS Compiler/uartecho
 */
#include <stdint.h>

/* POSIX Header files */
#include <mqueue.h>

/* XDC module Headers   */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* TI-RTOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Mailbox.h>

/* Example/Board Header files */
#include <ti/drivers/Board.h>
#include <ti/drivers/GPIO.h>

#include "Board.h"

#include "myMailbox.h"

//extern void *mainThread(void *arg0);
//extern void *alarmThread(void *arg0);
extern Void *mainThread(UArg arg0);
extern Void *alarmThread(UArg arg0);

/* Stack size in bytes */
#define STACKSIZE          1024

#define MSG_SIZE           sizeof(int)
#define MSG_NUM            4

mqd_t mqdes;

/*
 *  ======== main ========
 */
int main(void)
{
    /* Construct BIOS Task */
    Task_Struct task0Struct;
    Task_Struct task1Struct;
    Char        task0Stack[STACKSIZE];
    Char        task1Stack[STACKSIZE];

    struct mq_attr      mqAttrs;

    /* Call driver init functions */
    Board_init();
    GPIO_init();

    /* Configure the LED pin */
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);

    mqAttrs.mq_flags = 0;
    mqAttrs.mq_maxmsg = MSG_NUM;
    mqAttrs.mq_msgsize = MSG_SIZE;
    mqdes = mq_open ("alarm", O_RDWR | O_CREAT, 0664, &mqAttrs);
    if (mqdes == (mqd_t)-1) {
      /* mq_open() failed */
      while (1);
    }

    /* Initialize the attributes structure with default values */
    Task_Params taskParams;
    Task_Params_init(&taskParams);

    /* Set priority, detach state, and stack size attributes */
    taskParams.arg0 = (UArg)&mqdes;
    taskParams.priority = 1;
    taskParams.stack = &task0Stack;
    taskParams.stackSize = STACKSIZE;
//  taskParams.instance->name = "uartecho";
    Task_construct(&task0Struct, (Task_FuncPtr)mainThread, &taskParams, NULL);


    /* Make the alarm thread a higher priority.  */
    taskParams.arg0 = (UArg)&mqdes;
    taskParams.priority = 2;
    taskParams.stack = &task1Stack;
//  taskParams.instance->name = "alarm";
    Task_construct(&task1Struct, (Task_FuncPtr)alarmThread, &taskParams, NULL);

    BIOS_start();

    return (0);
}

************    uartecho.c  **********************************

#include <stdint.h>
#include <stddef.h>

/* POSIX Header files */
#include <mqueue.h>

/* XDC Module Headers */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS module Headers */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Mailbox.h>

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

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

/*
 *  ======== mainThread ========
 */
Void *mainThread(UArg arg0)
{
    char        input;
    const char  echoPrompt[] = "Echoing characters:\r\n";
    UART_Handle uart;
    UART_Params uartParams;

    int         msg;
    int         i;

    mqd_t       *mqDes = (mqd_t *)(arg0);

    /* Call driver init functions */
    UART_init();

    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;

    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        /* UART_open() failed */
        while (1);
    }

    UART_write(uart, echoPrompt, sizeof(echoPrompt));

    /* Loop forever echoing */
    while (1) {
        UART_read(uart, &input, 1);
        if (input == 'X') {
            msg = 5;
            i = mq_send(*mqDes , (char *)&msg, sizeof(msg), 0);
        }
        UART_write(uart, &input, 1);
    }
}

************    alarm.c  **********************************

/* POSIX Header files */
#include <mqueue.h>

/* BIOS module Headers */
#include <ti/sysbios/BIOS.h>

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

/* Board Header file */
#include "Board.h"

/*
 *  ======== alarmThread ========
 */
Void *alarmThread(UArg arg0)
{
    int msg;
    int i;

    mqd_t  *mqDes = (mqd_t  *)(arg0);

    while ((i = mq_receive(*mqDes, (char *)&msg, sizeof(msg), NULL)) != -1) {
        GPIO_toggle(Board_GPIO_LED0);       // Toggle user LED
    }

    return(0);
}

**Attention** This is a public forum