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.

CC1352R: Adding second task to ProjectZero fails unless added task's priority higher than ProjectZero_taskFxn

Part Number: CC1352R

CC1352R, SDK version 4.10.00.78

Starting with BLE5 Project Zero, I added a second task following the instructions in the user guide.

int main()
{    
    <...>

    ProjectZero_createTask();
    ValveTimerTask_createTask(); /* <-- Newly-added task */

    /* enable interrupts and start SYS/BIOS */
    BIOS_start();

    return(0);
}
static void ValveTimerTask_init(void)
{
    /* ******************************************************************
     NO STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
     ******************************************************************
     Register the current thread as an ICall dispatcher application
     so that the application can send and receive messages via ICall to Stack.
     *
     */
    ICall_registerApp(&selfEntity, &syncEvent);
}

The second task itself currently does nothing:

static void ValveTimerTask_taskFxn(UArg a0, UArg a1)
{
    ValveTimerTask_init();

    while (1) {
        uint32_t valve_timer_events;

        valve_timer_events = Event_pend(Event_handle(&timer_event),
                                        Event_Id_NONE,
                                        (uint32_t)VALVETIMER_ALL_EVENTS,
                                        (uint32_t)BIOS_WAIT_FOREVER);
    }
}

Everything works fine as long the task priority is set higher than Project Zero (whose priority is 1)

#define VALVE_TASK_PRIORITY       2
#define VALVE_TASK_STACK_SIZE     600

But if I set VALVE_TASK_PRIORITY to 1, the application does NOT get to the line which would print:

static void ProjectZero_processGapMessage(gapEventHdr_t *pMsg)
{
    switch(pMsg->opcode)
    {
    case GAP_DEVICE_INIT_DONE_EVENT:
    {            

           <...>

           Log_info1("GAP is started. Our address: " \
                      ANSI_COLOR(FG_GREEN) "%s" ANSI_COLOR(ATTR_RESET),
                      (uintptr_t)addrStr);

However if I debug the program and pause it, there are no exceptions; the program is in every other way executing normally. Even ROV doesn't show any issues. It is not just the UART logging that has failed either, the device cannot be seen by a phone either.

Note everything works fine when I set the second task's priority to 2. Why can't these tasks run with the same priority?

  • Hi,

    Thank you for all the details you have provided. As long as the priority of the new task is lower than the BLE task you should be fine.

    It is also important to verify if the number of allowed of ICall enabled task is correct (see the value of ICALL_MAX_NUM_TASKS) [however the default value of ICALL_MAX_NUM_TASKS should allow you to register at least one more ICall enabled task]

    To identify the problem, keep using the ROV, especially the "task" menu. You will see if the task projectZero task is running (s probably trapped in an error-handler) or basically blocked.

    Keep us updated!

    Kind regards,