XMC Peripheral Library for XMC4000 Family: WDT

XMC Peripheral Library for XMC4000 Family

XMC Peripheral Library for XMC4000 Family  2.1.16

Data Structures

struct  XMC_WDT_CONFIG_t
 

Enumerations

Functions

void XMC_WDT_ClearAlarm (void)
 
void XMC_WDT_Disable (void)
 
void XMC_WDT_Enable (void)
 
uint32_t XMC_WDT_GetCounter (void)
 
void XMC_WDT_Init (const XMC_WDT_CONFIG_t *const config)
 
void XMC_WDT_Service (void)
 
void XMC_WDT_SetDebugMode (const XMC_WDT_DEBUG_MODE_t debug_mode)
 
void XMC_WDT_SetMode (XMC_WDT_MODE_t mode)
 
void XMC_WDT_SetServicePulseWidth (uint8_t service_pulse_width)
 
void XMC_WDT_SetWindowBounds (uint32_t lower_bound, uint32_t upper_bound)
 
void XMC_WDT_Start (void)
 
void XMC_WDT_Stop (void)
 

Detailed Description

The watchdog unit (WDT) improves the system integrity, by triggering the system reset request to bring the system back from the unresponsive state to normal operation.

This LLD provides the Configuration structure XMC_WDT_CONFIG_t and initialization function XMC_WDT_Init().
It can be used to:

  1. Start or Stop the watchdog timer. (XMC_WDT_Start() and XMC_WDT_Stop())
  2. Service the watchdog timer. (XMC_WDT_Service())
  3. Configure the service window upper bound and lower bound timing values. (XMC_WDT_SetWindowBounds())
  4. Enable the generation of the pre-warning event for the first overflow of the timer. (XMC_WDT_SetMode())
  5. Clear the pre-warning alarm event. It is mandatory to clear the flag during pre-warning alarm ISR, to stop generating reset request for the second overflow of the timer. (XMC_WDT_ClearAlarm())
  6. Suspend the watchdog timer during Debug HALT mode. (XMC_WDT_SetDebugMode())
  7. Configure service indication pulse width.(XMC_WDT_SetServicePulseWidth())

Enumeration Type Documentation

Defines debug behaviour of watchdog when the CPU enters HALT mode. Use type XMC_WDT_DEBUG_MODE_t for this enum.

Enumerator
XMC_WDT_DEBUG_MODE_STOP 

Watchdog counter is paused during debug halt.

XMC_WDT_DEBUG_MODE_RUN 

Watchdog counter is not paused during debug halt.

Defines working modes for watchdog. Use type XMC_WDT_MODE_t for this enum.

Enumerator
XMC_WDT_MODE_TIMEOUT 

Generates reset request as soon as the timer overflow occurs.

XMC_WDT_MODE_PREWARNING 

Generates an alarm event for the first overflow. And reset request after subsequent overflow, if not serviced after first overflow.

Function Documentation

void XMC_WDT_ClearAlarm ( void  )
Parameters
None
Returns
None
Description:
Clears pre-warning alarm by setting ALMC bit in WDTCLR register.
In pre-warning mode, first overflow of the timer upper window bound fires the pre-warning alarm. XMC_WDT_ClearAlarm() must be invoked to clear the alarm alarm. After clearing of the alarm, watchdog timer must be serviced within valid time window. Otherwise watchdog timer triggers the reset request up on crossing the upper bound value in a subsequent cycle.
Related APIs:
XMC_WDT_Service(), XMC_WDT_SetMode()
void XMC_WDT_Disable ( void  )
Parameters
None
Returns
None
Description:
Disables the clock and resets watchdog timer.
Note:
  1. Resets the registers with default values. So XMC_WDT_Init() has to be invoked again to configure the watchdog.
Related APIs:
XMC_WDT_Enable()
void XMC_WDT_Enable ( void  )
Parameters
None
Returns
None
Description:
Enables watchdog clock and releases watchdog reset.
This API is invoked by XMC_WDT_Init() and therefore no need to call it explicitly during watchdog initialization sequence. Invoke this API to enable watchdog once again if the watchdog is disabled by invoking XMC_WDT_Disable().
Note:
  1. It is required to configure the watchdog, again after invoking XMC_WDT_Disable(). Since all the registers are reset with default values.
Related APIs:
XMC_WDT_Init(), XMC_WDT_Disable()
uint32_t XMC_WDT_GetCounter ( void  )
Parameters
None
Returns
uint32_t Current count value of watchdog timer register (TIM). Range: [0H to FFFFFFFFH]
Description:
Reads current count of timer register (TIM).
Invoke this API before servicing or feeding the watchdog to check whether count is between lower and upper window bounds.
Related APIs:
XMC_WDT_Service()
void XMC_WDT_Init ( const XMC_WDT_CONFIG_t *const  config)
Parameters
configpointer to a constant watchdog configuration data structure. Refer data structure XMC_WDT_CONFIG_t for detail.
Returns
None
Description:
Initializes and configures watchdog with configuration data pointed by config.
It invokes XMC_WDT_Enable() to enable clock and release reset. Then configures the lower and upper window bounds, working mode (timeout/pre-warning), debug behaviour and service request indication pulse width.
Note:
  1. With out invoking this XMC_WDT_Init() or XMC_WDT_Enable(), invocation of other APIs like XMC_WDT_SetWindowBounds(), XMC_WDT_SetMode(), XMC_WDT_SetServicePulseWidth(), XMC_WDT_SetDebugMode(), XMC_WDT_Start(), XMC_WDT_GetCounter(), XMC_WDT_Service(), XMC_WDT_ClearAlarm() has no affect.
void XMC_WDT_Service ( void  )
Parameters
None
Returns
None
Description:
Services or feeds the watchdog by writing the Magic word in SRV register.
Service watchdog when count value of watchdog timer is between lower and upper window bounds. Successful servicing will reset watchdog timer (TIM register) to 0H and generate service indication pulse.
Note:
  1. invoking this API when count value of watchdog timer is less than window lower bound results wrong servicing and immediately triggers reset request.
Related APIs:
XMC_WDT_GetCounter(), XMC_WDT_SetWindowBounds(), XMC_WDT_SetServicePulseWidth()
void XMC_WDT_SetDebugMode ( const XMC_WDT_DEBUG_MODE_t  debug_mode)
Parameters
debug_moderunning state of watchdog during debug halt mode. Refer XMC_WDT_DEBUG_MODE_t for valid values.
Returns
None
Description:
Sets debug behaviour of watchdog by modifying DSP bit of CTR register.
Depending upon DSP bit, the watchdog timer stops when CPU is in HALT mode. The debug behaviour is initially set as XMC_WDT_DEBUG_MODE_STOP during initialization in XMC_WDT_Init(). Invoke this API to change the debug behaviour as needed later in the program.
void XMC_WDT_SetMode ( XMC_WDT_MODE_t  mode)
Parameters
modeis one of the working modes of the watchdog timer, i.e timeout or pre-warning. Refer XMC_WDT_MODE_t for valid values.
Returns
None
Description:
Sets watchdog working mode (timeout or pre-warning) by updating PRE bit of CTR register.
The working mode is set during initialization in XMC_WDT_Init(). Invoke this API to alter the mode as needed later in the program.
void XMC_WDT_SetServicePulseWidth ( uint8_t  service_pulse_width)
Parameters
service_pulse_widthspecifies Service indication pulse width in terms of fwdt. Range: [0H – FFH].
Returns
None
Description:
Sets service indication pulse width by updating SPW bit field of CTR register.
The service indication pulse (with width service_pulse_width + 1 in fwdt cycles) is generated on successful servicing or feeding of watchdog. The pulse width is initially set during initialization in XMC_WDT_Init(). Invoke this API to alter the width as needed later in the program.
void XMC_WDT_SetWindowBounds ( uint32_t  lower_bound,
uint32_t  upper_bound 
)
Parameters
lower_boundspecifies watchdog window lower bound in terms of watchdog clock (fWDT) cycles. Range: [0H to FFFFFFFFH].
upper_boundspecifies watchdog window upper bound in terms of watchdog clock (fWDT) cycles. Range: [0H to FFFFFFFFH].
Returns
None
Description:
Sets watchdog window lower and upper bounds by updating WLB and WUB registers.
Window lower and upper bounds are set during initialization in XMC_WDT_Init(). Invoke this API to alter the values as needed later in the program. This upper bound and lower bound can be calculated by using the below formula
upper_bound or lower_bound = desired_boundary_time(sec) * fwdt(hz)
Note:
  1. Always ensure that upper_bound is greater than the lower_bound value. If not, whenever timer crosses the upper_bound value it triggers the reset(wdt_rst_req) of the controller.
void XMC_WDT_Start ( void  )
Parameters
None
Returns
None
Description:
Start the watchdog timer by setting ENB bit of CTR register.
Invoke this API to start the watchdog after initialization, or to resume the watchdog when paused by invoking XMC_WDT_Stop().
Related APIs:
XMC_WDT_Init(), XMC_WDT_Stop()
void XMC_WDT_Stop ( void  )
Parameters
None
Returns
None
Description:
Pauses watchdog timer by resetting ENB bit of CTR register.
Invoke this API to pause the watchdog as needed in the program e.g. debugging through software control.
Related APIs:
XMC_WDT_Init(), XMC_WDT_Stop()
Generated on Mon Aug 7 2017 11:33:57 for XMC Peripheral Library for XMC4000 Family by   doxygen 1.8.11