2010-07-07 03:28 AM
I am developing an application with STR750 and I use the watchdog timer in watchdog mode.
I have to fix a watchdog issue and find where my application code in some working conditions stops refreshing the watchdog timer. So I changed the watchdog in timer mode, in order to get a FIQ interrupt when that issue occurs. The following is my code:void WDG_Configuration(void)
{ WDG_InitTypeDef WDG_InitStructure; EIC_FIQInitTypeDef EIC_FIQInitStructure; WDG_DeInit();/* Configure the WDG to generate a FIQ interrupt */
WDG_InitStructure.WDG_Mode = WDG_Mode_Timer; WDG_InitStructure.WDG_Preload = 0xFFFF; WDG_InitStructure.WDG_Prescaler = 0xFF; WDG_Init(&WDG_InitStructure);/* Enable the WDG */
WDG_Cmd(ENABLE); WDG_ClearITPendingBit(); /* Enables the WDG End of Count(EC) interrupt */ WDG_ITConfig(ENABLE); EIC_FIQInitStructure.EIC_FIQChannel = WATCHDOG_FIQChannel; EIC_FIQInitStructure.EIC_FIQChannelCmd = ENABLE; EIC_FIQInit(&EIC_FIQInitStructure);EIC_ClearFIQPendingBit(WATCHDOG_FIQChannel);
/* Enable the Interrupt controller to manage FIQ channel*/ EIC_FIQCmd(ENABLE); }void WdogRefresh( void )
{ WDG_ClearFlag(); WDG_Cmd(ENABLE); } void FIQ_Handler(void) { unsigned char fiq_pend = (unsigned char)(EIC->FIPR); if( fiq_pend & 0x02 ) { /* Clear the FIQ pending bit for Watchdog */ EIC->FIPR = 0x00000002 ;if( (WDG->SR & 0x0001) && (WDG->MR & 0x0001) )
{ /* Clear the EC pending bit */ WDG->SR &= ~0x0001; /* Stop timer by clearing SC bit in Control register */ WDG->CR &= 0xFFFD; // endless loop for debbugging purpose while(1); } } if( fiq_pend & 0x01 ) { /* Clear the FIQ pending bit for EXTINT0 */ EIC->FIPR = 0x00000001 ; } }Well, when my application start running after watchdog initialization I get a FIQ interrupt for watchdog End of Count. Actually the EC flag in WDG Status Register is high: how can it be possible? Is my WdogRefresh() function wrong?
I have no watchdog reset at application startup when the watchdog timer is in watchdog mode ... Is there any appnote regarding the use of STR75x watchdog timer in timer mode? Waiting your kind help to resolve this issue ... thanks! #str75x-watchdog #str75x-watchdog2010-07-07 06:46 AM
It seems that the right wtchdog timer refresh function should be the following:
void WdogRefresh( void ) { WDG_Cmd(DISABLE); WDG_ClearFlag(); WDG_ClearITPendingBit(); EIC_ClearFIQPendingBit(WATCHDOG_FIQChannel); WDG_Cmd(ENABLE); } Should the watchdog timer be stopped and then restarted to avoid the End of Count event?