xTimerChangePeriod - Hanging up doesn't appear to return

Hi,

I have a timer (getTimeUpdateTmr) that sets a flag to initiate a real time clock update every 6 hours.

#define UPDATE_TIME_INTERVAL (6 * 3600 * 1000)

__inline setTimeError_t setRTC_ToNetworkTimeDate(const bool printToUart, bool* validTime)
{
	struct tm *gtime;

	wiFiPars.networkBusy = true;
	xTimerChangePeriod(getTimeUpdateTmr, UPDATE_TIME_INTERVAL, 50); /* TODO */

If I have an error in the update routine I wish to change the getTimeUpdateTmr’s duration to a shorter value to cause the RTC update to occur more often.

At the start of the RTC update function (setRTC_ToNetworkTimeDate) I set the timer back to 6 Hours; the UPDATE_TIME_INTERVAL.

However the xTimerChangePeriod causes the system to hang in the xTimerGenericCommand.


BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait )
{
BaseType_t xReturn = pdFAIL;
DaemonTaskMessage_t xMessage;

	configASSERT( xTimer ); <<<< hangs here

	/* Send a message to the timer service task to perform a particular action
	on a particular timer definition. */
	if( xTimerQueue != NULL )

The setRTC_ToNetworkTimeDate is called from a statically defined task. I do not call any functions from interrups apart from notifications and sem’s. The system runs fine without the xTimerChangePeriod included in the build.

WIFI_StatusTypeDef startWiFiSystem()
{
	wiFiTskHandle = xTaskCreateStatic( wiFiTask,
									 "wifiTask",
									 STACK_SIZE_WIFI_TASK,
									 NULL,
									 PRIO_WI_FI_TASK,   /* TODO - Review priorities */
									 wiFiTaskStack,
									 &wiFiTskBuffer);
	if(wiFiTskHandle == NULL)
	{
		return WIFI_XPORT_TASK_FAILED;
	}

	rtosTaskStates.wiFiTask = eRunning;
#if(ENABLE_COMMS_TIMEOUT == 1)
#endif
	return WIFI_OK;
}

The wiFiTask calls the setRTC_ToNetworkTimeDate when the getTimeUpdateTmr function callback set the flag read by the wiFiTask.

I’m not sure what I am doing wrong, any ideas?

Best regards
Rob

This assert means that xTimer is NULL. Can you check if the timer handle that you are passing is valid?

Hi,

Thanks

Will do.

Regards

Rob

Hi,

Fixed it. Hadn’t initialized the time before the first call to the function.

Silly me!

Regards
Rob

Thank you for reporting back!