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/TI-RTOS-MCU: Problem with hardware initialization tasks

Part Number: TI-RTOS-MCU
Other Parts Discussed in Thread: CC2640R2F

Tool/software: Code Composer Studio

Hello, I'm having some problems with initializing hardware with tasks. I have these two tasks which will initialize the SPI and a Timer working as an interruption source. I want to run these tasks only once, so I'm putting them at a really high priority and then calling Task_exit() in the end to delete them later on.
It's not working very well as this code is giving me a gigantic negative number for the priority of the SPI task in ROV. Also, if I run only the timer task, it never terminates and I don't know why (it should, right? Even without the Task_exit()).


I'm using the blestack with another thread with is executing with the lowest priority next to Idle, which runs my bluetooth application - that in turn relies on the timer and spi -. Can anyone help out? Thanks.

/* TIMER TASK */
#define TIMER_TASK_PRIORITY 6
#define TIMER_TASK_STACK_SIZE 512

/*SPI TASK*/
#define SPI_TASK_PRIORITY 7
#define SPI_TASK_STACK_SIZE 512

...

void spiCreateTask(void){

    Task_Params taskParams;

     Task_Params_init(&taskParams);
     taskParams.stack = spiTaskStack;
     taskParams.stackSize = SPI_TASK_STACK_SIZE;
     taskParams.priority = SPI_TASK_PRIORITY; //Same as before, defaults to some value in Task_construct

     spiTask = Task_create((Task_FuncPtr)spiConfigTaskFunction, &taskParams, NULL);

}

void timerConfigTaskFunction()
{
    DEBUG("TIMER TASK CONFIG FUNCTION");
    GPTimerCC26XX_Params params;
    GPTimerCC26XX_Params_init(&params);
    params.width          = GPT_CONFIG_16BIT;
    params.mode           = GPT_MODE_PERIODIC_UP;
    params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
    hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, &params);
    if(hTimer == NULL) {
        Task_exit();
    }

    Power_setDependency(PowerCC26XX_XOSC_HF);
    Types_FreqHz freq;
    BIOS_getCpuFreq(&freq);

    GPTimerCC26XX_Value loadVal = freq.lo / 10000 - 1; //47999
    GPTimerCC26XX_setLoadValue(hTimer, loadVal);
    GPTimerCC26XX_registerInterrupt(hTimer, (GPTimerCC26XX_HwiFxn)timerCallback, GPT_INT_TIMEOUT);
    //GPTimerCC26XX_start(hTimer); Where to start?
    //System_printf("...")

    Task_exit();
}

void timerCreateTask(void)
{
  Task_Params taskParams;

  Task_Params_init(&taskParams);
  taskParams.stack = timerTaskStack;
  taskParams.stackSize = TIMER_TASK_STACK_SIZE;
  taskParams.priority = TIMER_TASK_PRIORITY; //Same as before, defaults to some value in Task_construct

  timerTask = Task_create((Task_FuncPtr)timerConfigTaskFunction, &taskParams, NULL);

  if (timerTask == NULL){
      System_abort("Error creating timer task.");
  }

}


  • Hi,
    Which device is this? Which Processor SDK RTOS?
    Best Regards,
    Yordan

  • Hi Yordan, this is a CC2640R2F, I'm using SimpleLink 1.35. I'm also using the BLE stack to run a serial port profile, however I'm also experiencing the very same problems when I don't initialize any bluetooth-related tasks.

    Thank you.

  • Hi, so I actually managed to find out where my error is.

    Line 43 should be

    GPTimerCC26XX_registerInterrupt(hTimer, (GPTimerCC26XX_HwiFxn)&timerCallback, GPT_INT_TIMEOUT);
    

    No, the compiler did not catch that.

    I'm still having a bit of a trouble with the big negative number on the ROV. If I don't run the SPI initialization task, everything runs smoothly. I tried:

    1) Running the SPI and Timer initialization both at priority number 6. Same error with the ridiculous negative number on the priority of the other task I want to run, which is at priority number 2, and the timer initialization task never stopped running.

    2) Running the SPI and Timer initializations at the same priority level, but blocking the other problematic task with a Semaphore_pend() and Semaphore_post() on the SPI thread. This also didn't work, and the timer initialization task also never stopped running.

    Also, the DEBUG() interface does not work when this error occurs.

  • Hi Leon,

    Please run the BLE task (ICall task) at the highest priority.