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.

RTOS/CC2650: Unable to Run Two Tasks Simultaneously

Part Number: CC2650

Tool/software: TI-RTOS

Hello,

I have two applications I'm trying to develop for a custom cc2650 board. One of my tasks is a modification of the project zero code, while the other task uses serial to communicate with a loraWan chip and interacts with an Eink display as well. I have been trying to start the two tasks and run them simultaneously, but have been unsuccessful so far. Below is all the things I've done so far:

1. I noticed that according to the BLE development guide all my application tasks should be of lower priority than the GAP role task at the very least. So I made both my application tasks priority 1 and my GAP role task priority 3 and ICall_remote tasks priority 5. 

2. Given that my application tasks both run at the same priority I also ensured they yield to each other using a call to Task_sleep(SLEEP_TIME).

I have confirmed that both of my tasks work individually in the code base, but when I try running the two together, neither of them seem to work. What could be the reason I'm not able to run the tasks?

Thanks!

Best,

Abhinand

  • Hello Abhinand,

    I would suggest going through the SimpleLink Academy TI-RTOS module to gain a better understanding of RTOS and how to use the ROV for debugging. Also, using task sleep to synchronize tasks is probably not a solid solution. What happens when one task, say the BLE app task, blocks on a SEM or Event pend?

    Best wishes
  • Hi Abhinand Sukumar,

    Example my code about read/process data on serial of CC26xx on the second task. I have the first task for the app layer and the second task for serial.

    The tasks should be communicated through the queue.

    void FIOT_UART_Serial_Rx_Cb(UART_Handle iHandle, void *oData, size_t count)
    {  
      //!***********************************************
      //!Copy UART_Rx_Buf to UART_Tx_Buf
      //!***********************************************	
    
      //!***********************************************
      //!Wake task to process
      //!***********************************************		
      Semaphore_post(UART_hSem);
    } 
    /********************************************************************************
     * FUNCTIONS - TASK
     ********************************************************************************/
    /*!
     ********************************************************************************
     * @fn      void FIOT_UART_CreateTask(void)
     * 
     * @brief   Task creation function for the protocol
     * 
     * @param   None
     * 
     * @return  None
     *
     ********************************************************************************/ 
    void FIOT_UART_CreateTask(void)
    {
      Task_Params TaskParams;
      //!***********************************************
      //!Configure task
      //!***********************************************	
      Task_Params_init(&TaskParams);
      TaskParams.stack 			= UART_TaskStack;
      TaskParams.stackSize 	= UART_TASK_STACK_SIZE;
      TaskParams.priority 	= UART_TASK_PRIORITY;
    
      Task_construct(&UART_TaskStruct, FIOT_UART_TaskFxn, &TaskParams, NULL);
    }
    /*!
     ********************************************************************************
     * @fn      void FIOT_UART_InitTask(void)
     * 
     * @brief   Initilize UART layer
     * 
     * @param   None
     * 
     * @return  None
     *
     ********************************************************************************/
    void FIOT_UART_InitTask(void)
    {
      //!***********************************************
      //!Initilize UART
      //!***********************************************
      UART_Params uParams;
    	
      UART_Params_init(&uParams);
      
      uParams.writeDataMode  = UART_DATA_BINARY;
      uParams.readDataMode   = UART_DATA_BINARY;
      uParams.readReturnMode = UART_RETURN_FULL;
      uParams.readMode       = UART_MODE_CALLBACK;
      uParams.readCallback   = FIOT_UART_Serial_Rx_Cb;
    
      UART_uHandle = UART_open(Board_UART,&uParams);	
      //!***********************************************
      //!Initilize Semaphore
      //!***********************************************	
      Semaphore_Params sParams;
      Semaphore_Params_init(&sParams);
      sParams.mode = Semaphore_Mode_BINARY;
    
      Semaphore_construct(&UART_sSem, 0, &sParams);
      UART_hSem = Semaphore_handle(&UART_sSem);	
    }
    /*!
     ********************************************************************************
     * @fn      void FIOT_UART_TaskFxn(UArg a0, UArg a1)
     * 
     * @brief   Application task entry point for the protocol.
     * 
     * @param   a0, a1 - not used.
     * 
     * @return  None
     *
     ********************************************************************************/
    void FIOT_UART_TaskFxn(UArg a0, UArg a1)
    {				
      //!***********************************************
      //!Initilize uart layer
      //!***********************************************	
      FIOT_UART_InitTask();
      //!***********************************************
      //!Loop of uart layer
      //!***********************************************		
      for (;;)
      {
        //!***********************************************
        //!Refesh to read new Data
        //!***********************************************	  
        UART_read(UART_uHandle, &UART_Rx, 1);
    
        Semaphore_pend(UART_hSem, BIOS_WAIT_FOREVER);
        //!***********************************************
        //!Process Data
        //!***********************************************	
      }
    }

  • Thanks so much!