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.

TM4C1290NCPDT: Watchdog

Part Number: TM4C1290NCPDT
Other Parts Discussed in Thread: CC3100BOOST

Dear team

	#if (INT_WDOG_ENABLED)

/// Initialize the watchdog
void watchdog_init()
{ 
U4	u4_temp;
	
	for (u4_temp = 0; u4_temp < 500000L; u4_temp++) ;
	
	SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
	while(!SysCtlPeripheralReady(SYSCTL_PERIPH_WDOG0)) ;

    // Turn on stalling so the debugger doesn't reset the board.
    WatchdogStallEnable(WATCHDOG0_BASE);

    // Initialize the watchdog timer to an initial value of 6s
    WatchdogReloadSet(WATCHDOG0_BASE, g_SysClock*6);
    WatchdogResetEnable(WATCHDOG0_BASE);  // Enable the reset.
//    WatchdogEnable(WATCHDOG0_BASE);    // Enable the watchdog timer.  This function is not called as this function & WatchdogIntEnable() are same
}

// Routine called from infinite loop in the main function to refresh the watchdog
void watchdog_refresh(void)
{
	WatchdogReloadSet(WATCHDOG0_BASE, g_SysClock*6);			// Reload value is 6 seconds. So the time out for WatchDog Reset is 12 Seconds
}
	#endif

int main(void)
{
U1	u1_key_code;
U4	u4_signature;
BIT	fl_led_on;
		
	SystemCoreClockUpdate();              		// Update SystemCoreClock variable

	IntMasterDisable();							//Disable all interrupts
	init_devices_main();
	init_flags();
	init_variables();
	
	init_modules();							// Initialize the various software modules used
	SysTick_Config(g_SysClock/1000-1);		// Generate interrupt each 1 ms
	nvm_init();

	u4_mscount = 0;
	u1_disp_data = 'A';

	SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;

	status_led_on();
	error_led_on();
	delay1();
	status_led_off();
	error_led_off();
	delay1();

	nvm_readSequence(ADR_SIGNATURE, (U1*) &u4_signature,4);

	if (u4_signature != U2_NVM_SIGNATURE)
	{
		u4_signature = U2_NVM_SIGNATURE;
		nvm_writeSequence(ADR_SIGNATURE, (U1*) &u4_signature,4);
		nvm_readSequence(ADR_SIGNATURE, (U1*) &u4_signature,4);
		if (u4_signature != U2_NVM_SIGNATURE)
		{
			uputs(0,3,20," EEPROM ERROR !!!   ");
			disp_val(14,3,u4_signature,5,0);
			wait_1s();
			wait_1s();
			wait_1s();
		}
		master_clear(U1_CALIB_ERASE);
	}
	else
	{
		load_settings();
		load_results();
		load_calibration();
		load_configuration();
		load_rules();
		
		// Post NVM Load function calls
		RuleEng_decode_rules();
	} 

	IntMasterEnable();							//Enable all interrupts

	#if (INT_WDOG_ENABLED)
	watchdog_init();
	#endif
	
	clr_display();
	u1_disp_mode = U1_NORMAL_DISP_MODE1;  

	fl_socket_connected = FALSE;
	fl_dump_socket_connected = FALSE;
	wifi_connection_status = WiFi_CC3100_connect2AP();

	if (wifi_connection_status == 0)
	{
		if (WiFi_Socket_open() == 1) fl_socket_connected = TRUE;
		else fl_socket_connected = FALSE;
		
	}

	fl_led_on = FALSE;

	while (1)
	{
		#if (INT_WDOG_ENABLED)
		watchdog_refresh();
		#endif
		
		do_process();
		disp_led_status();
		RtcReadTime();

		if ((fl_socket_connected == TRUE) && (wifi_connection_status == 0))
		{
			if (fl500ms_event != FALSE)
			{
				fl500ms_event = FALSE;
				if (fl_led_on == TRUE) 
				{
					error_led_off();
					fl_led_on = FALSE;
				}
				else
				{
					error_led_on();
					fl_led_on = TRUE;
				}
			}
		}
		else 
		{
			if (fl_led_on == TRUE)
			{
				fl_led_on = FALSE;
				error_led_off();
			}
			else
			{
				fl_led_on = TRUE;
				error_led_on();
			}
		}
		
		if (fl_socket_connected != TRUE)
		{
			if (WiFi_Socket_open() == 1) 
			{
				fl_socket_connected = TRUE;
			}
			else 
			{
				wifi_connection_status = WiFi_CC3100_connect2AP();
				if (wifi_connection_status == 0)
				{
					if (WiFi_Socket_open() == 1) fl_socket_connected = TRUE;
				}
			}	
		}
	}
}

We would like take the technical support of TI for one of our product development with TI Microcontroller.

For Textile industries, we have developed a product with TI Microcontroller TM4C129ENCPDTI3R with CC3100BOOST and we have enabled the internal watchdog in TM4C129 with timeout period of 12 seconds to reset the system.

We understood in many cases, if there are timeouts the systems gets reset. But in few cases, the watchdog reset did not happen.

Please find attached the code (part) relating to the watchdog module (init, refresh etc).

Could you please check the possibility of this situation and support us to resolve this issue.

  • Deng,
    You are reloading the dog on every cycle inside your main loop. So, unless one of those other tasks locks up, you would not expect a reset, correct?
    If that is correct, is the timeout reset something that you DO NOT expect? How (if so) are you forcing a lock up to test the watchdog?
    Bruno
  • Code you use paste code (the </> icon)? I don't download files.

    Robert
  • Deng,
    Like Bruno said, you are calling the watchdog_refresh() to reload the WD counter in the while loop. Unless the rest of the tasks inside the while loop are taking longer than the WD is refreshed, the WD will not reset.

    #if (INT_WDOG_ENABLED)
    watchdog_refresh();
    #endif
  • Thanks for your reply.

    Yes. You are right. If the ‘reset of the tasks in while loop takes longer time’ then Reset should occur. That was the intention.

    The watchdog timeout period is around 12 seconds (1st timeout in 6th second and then 2nd timeout to reset the MCU is on 12th Second). If the reset of the tasks in while loop takes more than 12 seconds, then the reset should occur. Could you please confirm that this requirement could be met with the code that we had shared with you.

    Do you see any possible reason for the processor not getting reset even after 12 seconds (beyond the timeout period). watchdog_refresh() is called only in the while loop in main() function.

    Thanks once again for you time and support.

    Best Regards
  • Green Deng said:
    Could you please confirm that this requirement could be met with the code that we had shared with you.

    The concept is correct and it should work. As for "can we confirm", I'd say that this is for you to test - it is your code and development. As a suggestion, you could put a test while in the main code, perhaps controlled by a push button - something like while(PUSH_BUTTON_IS_PRESSED){}. Or somehow force your external tasks to take longer than 12 seconds...

    Green Deng said:
    Do you see any possible reason for the processor not getting reset even after 12 seconds

    Again, the concept is correct - is there any bug or minor mistake? That's normally for the developer to test and verify. Could you do that and post back your results? I particularly find that 12 seconds for a watchdog is a hell of an excessive time... can't think of any reasonable single-thread application that could consume that much and still be a healthy piece of code.

    Regards

    Bruno