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/CC2640R2F: ROV report wrong stack size

Part Number: CC2640R2F

Tool/software: Code Composer Studio

Hi team

ROV seems to report wrong stack size for 2 of my tasks. I have only 3 task, 2 application task and 1 system default idle task. 

It will report correct stack size if I set task stack size to 400, 512, and 1024. If I set the stack size less than 400, it seem to report wrong stack size.

For example, if I set both the stack size to 300, the ROV will report stack size are 296 bytes for both of my task, and their stack Peak are 272 and 216, both still under the 300 bytes limit. However, the tasks seem to run fine. 

What have I done wrong??

Here is how I set up my tasks:

/*
 * blink.c
 *
 *  Created on: Nov 12, 2019
 *      Author: James Wu
 */

/* Application Headers */
#include "test.h"



void test_print(void){
    System_printf("hello world, call point test print!\n");
    System_flush();
}


static Task_Params taskParams;
Task_Struct taskTestStruct;
static uint8_t taskStack[TASK_TEST_STACKSIZE];

void task_test_init(void){
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASK_TEST_STACKSIZE;
    taskParams.priority = TASK_TEST_PRIORITY;
    taskParams.stack = &taskStack;

    Task_construct(&taskTestStruct, task_test_blinky, &taskParams, NULL);

}


void task_test_blinky(UArg arg0, UArg arg1){

//    /* test LEDs */
//    const PIN_Config pinTable[] = {
//                             MYBOARD_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
//                             MYBOARD_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
//                             PIN_TERMINATE
//    };
//
//    PIN_Handle pinHandle;
//    PIN_State pinState;
//
//    pinHandle = PIN_open(&pinState, pinTable);
//    if (pinHandle == NULL){
//        System_printf("PIN failed, system halt.\n");
//        System_flush();
//        while(1);
//    }
//
//    PIN_setOutputValue(pinHandle, MYBOARD_PIN_GLED, 0);
//    PIN_setOutputValue(pinHandle, MYBOARD_PIN_RLED, 0);

    /* test counter */
    uint16_t counter = 0;

    System_printf("Starting test task...\n");
    System_flush();

    while(1){
        /* sleep a little */
        Task_sleep(DELAY_1S);

        /* print out some message */
        System_printf("test task, counter = %d\n", counter++);
        System_flush();

        /* toggle LED */
        //PIN_setOutputValue(pinHandle, MYBOARD_PIN_GLED, !PIN_getOutputValue(MYBOARD_PIN_GLED));

    }
}

/*
 * leds.c
 *
 *  Created on: Nov 13, 2019
 *      Author: James Wu
 */

#include "leds.h"


static Task_Params taskParams;
Task_Struct taskLedsStruct;
static uint8_t taskStack[TASK_LEDS_STACKSIZE];

void task_leds_init(void){
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASK_LEDS_STACKSIZE;
    taskParams.priority = TASK_LEDS_PRIORITY;
    taskParams.stack = &taskStack;

    Task_construct(&taskLedsStruct, task_leds, &taskParams, NULL);
}

void task_leds(UArg arg0, UArg arg1){

    PWM_Handle hPwmRed, hPwmGreen;
    PWM_Params pwmParams;
    uint32_t stepValue = 5; // in us

    PWM_Params_init(&pwmParams);
    pwmParams.idleLevel = PWM_IDLE_LOW;
    pwmParams.periodUnits = PWM_PERIOD_US;
    pwmParams.periodValue = 1000;
    pwmParams.dutyUnits = PWM_DUTY_US;
    pwmParams.dutyValue = 0;

    hPwmGreen = PWM_open(MYBOARD_PIN_PWM0, &pwmParams);
    if (hPwmGreen == NULL){
        System_printf("PWMGreen failed, system halt.\n");
        System_flush();
        while(1);
    }

    hPwmRed = PWM_open(MYBOARD_PIN_PWM1, &pwmParams);
    if (hPwmRed == NULL){
        System_printf("PWMRed failed, system halt.\n");
        System_flush();
        while(1);
    }

    PWM_start(hPwmGreen);
    PWM_start(hPwmRed);

    uint32_t duty = 0;
    bool toggle = 1;

    System_printf("Starting LEDs task...\n");
    System_flush();

    while(1){
        Task_sleep(DELAY_1MS * 10);

        PWM_setDuty(hPwmGreen, duty);
        PWM_setDuty(hPwmRed, duty);

        if (toggle){
            duty = duty + stepValue;
            if (duty == pwmParams.periodValue) toggle ^= 1;
        }else{
            duty = duty - stepValue;
            if (duty == stepValue) toggle ^= 1;
        }
    }
}