Energy Micro IEC60355 Library Example Project 1.0 (internal use only!) GCC-Version
Example project demonstrating POST and BIST library functions

Watchdog Timer Test

POST test of WDOG unit and processing a reset
. More...

Collaboration diagram for Watchdog Timer Test:

Defines

#define SyncWDOGCTRL()   (WDOG->SYNCBUSY & WDOG_SYNCBUSY_CTRL)
#define SyncWDOGCMD()   (WDOG->SYNCBUSY & WDOG_SYNCBUSY_CMD)

Functions

testResult_t IEC60335_ClassB_initWDT (void)
 This function initializes the IEC60335 Class B WDT test for POST usage
the function will be called after reset and checks the reset conditions
The function will enable the WDOG module if the last reset condition was POR or EXT.
In this case the WDOG start counting and will cause a WDOG reset after a period of time.
Residing in the POST function the routine now will check for WDOG reset and return a pass result.
void IEC60335_ClassB_Refresh_WDT (void)
 This function represents the part of the IEC60335 Class B WDT test which has to be executed within a loop. It refreshes the WDT counter.
testResult_t IEC60335_ClassB_Force_WDT_Reset (void)
 This function starts the Watchdog and waits for positive reset conditions.

Detailed Description

POST test of WDOG unit and processing a reset
.

starting the WDOG will force a reset of the chip. a second entry to the functions will
be checked for a WDOG reset reason.


Define Documentation

#define SyncWDOGCMD ( )    (WDOG->SYNCBUSY & WDOG_SYNCBUSY_CMD)

Definition at line 45 of file iec60335_class_b_wdt_test.c.

Referenced by IEC60335_ClassB_Refresh_WDT().

#define SyncWDOGCTRL ( )    (WDOG->SYNCBUSY & WDOG_SYNCBUSY_CTRL)

Definition at line 44 of file iec60335_class_b_wdt_test.c.

Referenced by IEC60335_ClassB_initWDT().


Function Documentation

testResult_t IEC60335_ClassB_Force_WDT_Reset ( void  )

This function starts the Watchdog and waits for positive reset conditions.

(DO_NOT_INCLUDE_WITH_DOXYGEN)

Returns:
passed or failed. See testResult_t .
Note:
POST use only! The function will lead to a reset.
Attention:
The function may not work in debugging mode. The reset cause of the debugge is not obtained and
debugger interface may affect the WDOG runing conditions. If the reset occures the debugger may
fail reconnect the target without resetting it again.
WDOG-force.jpg

Definition at line 121 of file iec60335_class_b_wdt_test.c.

References IEC60335_ClassB_initWDT(), and IEC60335_testFailed.

Referenced by IEC60335_ClassB_POST().

{
  testResult_t result = IEC60335_testFailed;
  /* no debugger allowed here */
  result = IEC60335_ClassB_initWDT();

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

testResult_t IEC60335_ClassB_initWDT ( void  )

This function initializes the IEC60335 Class B WDT test for POST usage
the function will be called after reset and checks the reset conditions
The function will enable the WDOG module if the last reset condition was POR or EXT.
In this case the WDOG start counting and will cause a WDOG reset after a period of time.
Residing in the POST function the routine now will check for WDOG reset and return a pass result.

(DO_NOT_INCLUDE_WITH_DOXYGEN)

Returns:
passed or failed. See testResult_t .
Note:
debugging can affect the WDT behavior defined in the DEBUGRUN bit in the WDOG_CTRL register.
Attention:
This function must not be called outside the POST tests.
WDOG-init.jpg

Definition at line 56 of file iec60335_class_b_wdt_test.c.

References IEC60335_testFailed, IEC60335_testInProgress, IEC60335_testPassed, and SyncWDOGCTRL.

Referenced by IEC60335_ClassB_Force_WDT_Reset().

{
  testResult_t result = IEC60335_testFailed;
  uint32_t     resetcause;
  /* check for core locked condition */
  resetcause = RMU->RSTCAUSE;
  if (!(RMU->CTRL & (1 << _RMU_CTRL_LOCKUPRDIS_SHIFT)))
  {
    /* check POR or Ext-reset reset as last reset event */
    if ((resetcause == RMU_RSTCAUSE_PORST)
        || ((resetcause & RMU_RSTCAUSE_EXTRST) && ((~resetcause) & 0x3)))
    {
      /* enable LE clock */
      CMU->HFCORECLKEN0 |= CMU_HFCORECLKEN0_LE;
      /* clear flag */
      RMU->CMD     = RMU_CMD_RCCLR;
      EMU->AUXCTRL = EMU_AUXCTRL_HRCCLR;
      EMU->AUXCTRL = 0;
      /* init WDOG and start */
      while (SyncWDOGCTRL()) ;
      WDOG->CTRL = 0x80D;
      /* optional WDOG_CTRL_DEBUGRUN */
      result = IEC60335_testInProgress;
    }
    /* WDOG reset detected (second entry) */
    else if ((resetcause & RMU_RSTCAUSE_WDOGRST) && (~resetcause & 0x03))
    {
      /* test has been successful */
      result = IEC60335_testPassed;
      /* optional clear flag */
/*    RMU->CMD = RMU_CMD_RCCLR; */
    }
  }

  return result;
}

Here is the caller graph for this function:

void IEC60335_ClassB_Refresh_WDT ( void  )

This function represents the part of the IEC60335 Class B WDT test which has to be executed within a loop. It refreshes the WDT counter.

(DO_NOT_INCLUDE_WITH_DOXYGEN)

Attention:
This function must be called periodically inside a loop.
For this function, it is necessary to estimate the count how often this function could be called.
WDOG-refresh.jpg

Definition at line 100 of file iec60335_class_b_wdt_test.c.

References SyncWDOGCMD.

{
  /* If a previous clearing is being synchronized to LF domain, then there
   * is no point in waiting for it to complete before clearing over again.
   * This avoids stalling the core in the typical use case where some idle loop
   * keeps clearing the watchdog. */
  if (SyncWDOGCMD())
  {
    return;
  }

  WDOG->CMD = WDOG_CMD_CLEAR;
}