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/LAUNCHXL-CC1352R1: [RTOS] Task not executing the function pointer

Other Parts Discussed in Thread: LAUNCHXL-CC1352R1

art Number: LAUNCHXL-CC1352R1

Tool/software: Code Composer Studio

Hi Everyone,

I am having an issue with my script where in I start with an empty TI RTOS project. My goal is to run a basic Task that has a function pointer but in my script I wasn't able to make it work. Though there are no compile issues.

All codes below this line doesn't work.

task0 = Task_create((Task_FuncPtr) ledController, &taskParams, NULL);

Here is the full script of project.

/*
 * Copyright (c) 2015-2019, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ======== empty.c ========
 */

/* For usleep() */
#include <unistd.h>
#include <stdint.h>
#include <stddef.h>

#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

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

/* Driver configuration */
#include "ti_drivers_config.h"
#include <ti/drivers/UART.h>
#define STACKSIZE 512
UART_Handle uart;
char echoPrompt[] = "ERROR";

static void ledController(UArg arg0, UArg arg1)
{

    while (1)
    {
        GPIO_toggle(CONFIG_GPIO_LED_0);
        Task_sleep(50);
    }

}
/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{

    UART_Params uartParams;
    Task_Params taskParams;
    Task_Handle task0;

    GPIO_init();
    UART_init();
    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(CONFIG_UART_0, &uartParams);


    GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    Task_Params_init(&taskParams);
    taskParams.stackSize = 255;

    taskParams.priority = 15;

    task0 = Task_create((Task_FuncPtr) ledController, &taskParams, NULL);
    if(task0==NULL)
    {
        UART_write(uart, echoPrompt, sizeof(echoPrompt));
    }

    return (NULL);
}

and in my ROV View it says

Any help would be greatly appreciated.

Thank you and regards,

Jonathan

  • Hi Jonathan,

    Have you configured the heap? Since you aren't providing an already allocated stack when creating your Task, it will allocate the stack on the heap.

    Check out the heap in ROV to verify that the heap is working as expected.

    Also, have you tried debugging? Does the code crash somewhere?