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: Clock object not behaving properly.

Part Number: CC2650
Other Parts Discussed in Thread: CC1350

Tool/software: TI-RTOS

Hi,

In My application i am using the CC2650 example code for Sensor Tag.In my application i have the need of periodic reset of the sensor tag after 12 hour reboot.I am using the 

Util_constructClock(&ResetClock, Reset_clockHandler,RESET_PERIODIC_EVT_PERIOD, 0, true, 0);  function to create a clock with 12 hour reboot.and on the clock time out i am calling the system reboot function.But instead of 12 hours it is rebooting only in 4 minutes.I am not able to get into the root cause of the issue.

Here is the part of the code snippet ::

#define RESET_PERIODIC_ONE_MINUTE 60000
#define RESET_PERIODIC_TEN_MINUTE 600000
#define RESET_PERIODIC_FIFTEEN_MINUTE 900000
#define RESET_PERIODIC_ONE_HOUR 3600000
#define RESET_PERIODIC_TWELEVE_HOUR 43200000
// How often to perform periodic event (in msec)
#define RESET_PERIODIC_EVT_PERIOD RESET_PERIODIC_TWELEVE_HOUR

/*********************************************************************
* @fn Reset_clockHandler
*
* @brief Handler function for clock timeouts.
*
* @param arg - event type
*
* @return None.
*/
static void Reset_clockHandler(UArg arg)
{
SysCtrlSystemReset();
}

/*******************************************************************************
* Locals
*/
/*******************************************************************************
*
* @fn Main
*
* @brief Application Main
*
* input parameters
*
* @param None.
*
* output parameters
*
* @param None.
*
* @return None.
*/
int main()
{
uint32_t Random_Number;
/* Register Application callback to trap asserts raised in the Stack */
RegisterAssertCback(AssertHandler);

PIN_init(BoardGpioInitTable);

#ifdef CC1350_LAUNCHXL
// Enable 2.4GHz Radio
radCtrlHandle = PIN_open(&radCtrlState, radCtrlCfg);

#ifdef POWER_SAVING
Power_registerNotify(&rFSwitchPowerNotifyObj,
PowerCC26XX_ENTERING_STANDBY | PowerCC26XX_AWAKE_STANDBY,
(Power_NotifyFxn) rFSwitchNotifyCb, NULL);
#endif //POWER_SAVING
#endif //CC1350_LAUNCHXL

#ifndef POWER_SAVING
/* Set constraints for Standby and Idle mode */
Power_setConstraint(PowerCC26XX_SB_DISALLOW);
Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW);
#endif // POWER_SAVING

/* Initialize ICall module */
ICall_init();

/* Start tasks of external images - Priority 5 */
ICall_createRemoteTasks();

/* Kick off profile - Priority 3 */
GAPRole_createTask();

/* Kick off application - Priority 1 */
SensorTag_createTask();
SensorTagTmp_createTask();
SensorTagHum_createTask();
SensorTagBar_createTask();
/* Kick off application WatchDog */

// watchdog_initlize();

/* Intializes random number generator */
time_t foo = time(NULL);
srand(foo);
Random_Number=rand() %10000;
Random_Number +=RESET_PERIODIC_EVT_PERIOD;
// kick off clock object
// Create one-shot clocks for internal periodic events.
Util_constructClock(&ResetClock, Reset_clockHandler,RESET_PERIODIC_EVT_PERIOD, 0, true, 0);
// Util_startClock(&ResetClock);
BIOS_start(); /* enable interrupts and start SYS/BIOS */

return 0;
}

As per the calculation i am setting it as one shot timer and time out be = 1000*60*60*12 =43200000  . so it should be 12 hours.But this is behaving strange and getting the reboot in 4 minutes only.Any help would be greatly appreciated.

Regards,

Deepak

  • Hi,

    I have experienced that the code is working fine when i am giving the timeout period of 10 minutes. i.e. the value   #define RESET_PERIODIC_TEN_MINUTE 600000

    when i am incresing the period to 12 hours it is misbehaving.Overflow issue should not be there as the value  #define RESET_PERIODIC_TWELEVE_HOUR 43200000 is well within the range of the 32 bit.

    This problem is making me go crazy.Please help.

  • If i set the clock to 10 minutes and on the time out if i increase the counter and work in that manner. Will that be a good way to reboot the sensor.
  • Hello,

    What is the reset reason? Do you see a difference if you initialize from a task and not main? Did you check for stack overflow?

    Best wishes
  • Deepak Kumar25 said:
    /* Intializes random number generator */
    time_t foo = time(NULL);
    srand(foo);
    Random_Number=rand() %10000;
    Random_Number +=RESET_PERIODIC_EVT_PERIOD;
    // kick off clock object
    // Create one-shot clocks for internal periodic events.
    Util_constructClock(&ResetClock, Reset_clockHandler,RESET_PERIODIC_EVT_PERIOD, 0, true, 0);
    // Util_startClock(&ResetClock);
    BIOS_start(); /* enable interrupts and start SYS/BIOS */

    Hi Deepak Kumar25,

    I recommend you can see the SimpleBLEPeripheral project. You can try to change the period of timer in SimpleBLEPeripheral .c.

    You shouldnot use Util_constructClock without a task of RTOS

  • hi,
    I have constructed the clock in the main loop only.
  • HI JXS,
    No i do not see any difference between the two while calling from the main or from a task.It is working if it is a 10 minute clock timer but while i increase the timer value, it behaves wrongly.I have followed the example in SimpleBLEPeripheral project only. and it is creating problem.
  • Hi Deepak Kumar25,
    You generate a second timer like timer in SimpleBLEPeripheral. When timer is active, it will active an event. And wait until SimpleBLEPeripheral task is free to process it. The function of event is SysCtrlSystemReset();
  • HI Vy Luu, as per your instruction i did the clock struct in he a task but still it is behaving the same.I think it is related to the value of the timer.It is working fine when i give time up to 10 minutes but on increasing the timer value, it starts behaving abnormally.But as far as i can understand it is not a variable overflow issue as the value can normally come in a 32 bit value.
  • Hi,

    As far i have seen i have constructed the clock for 10 minutes and on the the clock event i am incrementing a counter and when the counter reaches a particular event then i reset the device.But the device is getting reset on the first counter itself.