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.

CC2642R-Q1: Multi-Role example - implement 1ms timer

Part Number: CC2642R-Q1

Tool/software:

Hello

I try to implement a control function for DRV8243 and for this, I prepare a timer. But when I call the function Timer_start, the processor freezes. could you please help me.

uint8_t status;
int *ptrInteger = &gui_deviceControlUpdateTask;
//(*fun_ptr) = &gui_deviceControlUpdateTask;

Timer_Params_init(&params);
paramstime.periodUnits = Timer_PERIOD_HZ;
paramstime.period = 1000;
paramstime.timerMode = Timer_CONTINUOUS_CALLBACK;
paramstime.timerCallback = *ptrInteger;
handletime = Timer_open(CONFIG_TIMER_0, &paramstime);
if (handletime == NULL) {
// Timer_open() failed
Display_printf(dispHandle, 13, 0, "drv824xInithandlefail: ");
}
status = Timer_start(handletime);
if (status == Timer_STATUS_ERROR) {
//Timer_start() failed
Display_printf(dispHandle, 14, 0, "drv824xInitfail: ");
}
//sleep(10000);
// Timer_stop(handletime);

  • Hello!

    I see two concerning lines in this code:

    int *ptrInteger = &gui_deviceControlUpdateTask;
    
    
    paramstime.timerCallback = *ptrInteger;
    

    The paramstime.timerCallback should be taking a function pointer, however, it looks like you're de-refencing an integer (I'm going off the naming of the variables).

    Do you mind giving me some more information on the code?

    Can I see the code for the callback?

    Best,

    Nima Behmanesh