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.

Clock callbacks are not getting called - CC1310

Hello,


I am not seeing the clock call back getting called.. I don't see the debug prints that I have added.  THe code compiles fine, however I don't see the msgs that I have added every 100ms (periodic timer)..   I have included the clock.h   in the header file.. Also I ensure that in the .cfg file the clock module has been selected.

Can you please suggest where the problem might be?

Void pa_bcs_invoke_controller_interrupt(UArg arg0)
{
  Bool exit_api = FALSE;

  Display_Params params;
      Display_Params_init(&params);
        params.lineClearMode = DISPLAY_CLEAR_BOTH;
        Display_Handle  lcdDisplayHandle1 = Display_open(Display_Type_LCD, &params);

  if (++display_line_num > 5)
  {
   display_line_num = 0;
  }
  Display_print0(lcdDisplayHandle1, ++display_line_num, 0, "PA_BCS: Invoke Controller \n");
  Semaphore_pend(semHandle1, BIOS_WAIT_FOREVER);
  while (1)

..........

 *  ======== main ========
 */
int main(void)
{
 Semaphore_Params semParams;
 Semaphore_Params semParams1;
    /* Call board init functions. */
    Board_initGeneral();

    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, pinTable);
    if(!ledPinHandle)
    {
        System_abort("Error initializing board LED pins\n");
    }

    /* Construct a Semaphore object to be use as a resource lock, inital count 1 */
    Semaphore_Params_init(&semParams);
    Semaphore_construct(&semStruct, 1, &semParams);

    /* Obtain instance handle */
    semHandle = Semaphore_handle(&semStruct);

    Semaphore_Params_init(&semParams1);
    Semaphore_construct(&semStruct1, 1, &semParams1);

   /* Obtain instance handle */
    semHandle1 = Semaphore_handle(&semStruct1);

    /* Construct BIOS Objects */
                /*Setup clock for every 100ms*/
      Clock_Params clkParams;
      Clock_Params_init(&clkParams);
      clkParams.period = 100000/Clock_tickPeriod;
      clkParams.startFlag = TRUE;

     /* Construct a periodic Clock Instance */
      Clock_construct(&clk0Struct, (Clock_FuncPtr)pa_bcs_invoke_controller_interrupt,
                         100000/Clock_tickPeriod, &clkParams);

      /* Initialize task */
          TaskInit();

    /* Start BIOS */
    BIOS_start();

    return (0);
}

Thanks,

krishna

  • You are calling Display Driver functions from your callback, it is not possible to do this in a HWI context, it must be done in a Task context. You need to configure the display in the Task and then post a semaphore or event from the clock callback and unblock the task function to write to the Display.
  • Thanks. Would you be able to provide an example for the same?

    Btw, I have also added the Sytem_printf  in the clock callback and I don't see those messages being outputted in the console as well

  • Hi,

    There are a few problems with your code. TopCat already mentioned one problem, but you are also using a Semaphore_pend inside your ISR which is not possible. I am not sure whether you didn't format your code properly, but the semaphore_pend would seize your MCU.

    What you will need to do:
    Create an additional semaphore to synchronize and signal your events. (with start count = 0)
    Create a task that will wait for the semaphore
    Post your semaphore inside your clock callback function

    Here is a skeleton of the code to show what you could do:

    void main(void){
      //do your init stuff here
    
      //Create and instantiate your clock here
    
      //Create a semaphore to notify of events (yourSemaphore)
    
      //Create a task here (in this case TaskFxn)
    
    BIOS_start();
    }
    
    Void TaskFxn(Uarg a0, UArga1){
      //Open your display here
      Display_Params params;
      Display_Params_init(&params);
      params.lineClearMode = DISPLAY_CLEAR_BOTH;
      Display_Handle  lcdDisplayHandle1 = Display_open(Display_Type_LCD, &params);
    
      Semaphore_pend(yourSemaphore);
    
      //Do you display and printf stuff here
      //you can add any kind of logic that you want here
    }
    
    Void pa_bcs_invoke_controller_interrupt(UArg arg0){
      Semaphore_post(yourSemaphore);
    }

    I hope this helps.

    Michel