MCUXpresso SDK API Reference Manual  Rev 2.12.1
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
WDOG32: 32-bit Watchdog Timer

Overview

The MCUXpresso SDK provides a peripheral driver for the WDOG32 module of MCUXpresso SDK devices.

Typical use case

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/wdog32

Data Structures

struct  wdog32_work_mode_t
 Defines WDOG32 work mode. More...
 
struct  wdog32_config_t
 Describes WDOG32 configuration structure. More...
 

Enumerations

enum  wdog32_clock_source_t {
  kWDOG32_ClockSource0 = 0U,
  kWDOG32_ClockSource1 = 1U,
  kWDOG32_ClockSource2 = 2U,
  kWDOG32_ClockSource3 = 3U
}
 Describes WDOG32 clock source. More...
 
enum  wdog32_clock_prescaler_t {
  kWDOG32_ClockPrescalerDivide1 = 0x0U,
  kWDOG32_ClockPrescalerDivide256 = 0x1U
}
 Describes the selection of the clock prescaler. More...
 
enum  wdog32_test_mode_t {
  kWDOG32_TestModeDisabled = 0U,
  kWDOG32_UserModeEnabled = 1U,
  kWDOG32_LowByteTest = 2U,
  kWDOG32_HighByteTest = 3U
}
 Describes WDOG32 test mode. More...
 
enum  _wdog32_interrupt_enable_t { kWDOG32_InterruptEnable = WDOG_CS_INT_MASK }
 WDOG32 interrupt configuration structure. More...
 
enum  _wdog32_status_flags_t {
  kWDOG32_RunningFlag = WDOG_CS_EN_MASK,
  kWDOG32_InterruptFlag = WDOG_CS_FLG_MASK
}
 WDOG32 status flags. More...
 

Unlock sequence

#define WDOG_FIRST_WORD_OF_UNLOCK   (WDOG_UPDATE_KEY & 0xFFFFU)
 First word of unlock sequence.
 
#define WDOG_SECOND_WORD_OF_UNLOCK   ((WDOG_UPDATE_KEY >> 16U) & 0xFFFFU)
 Second word of unlock sequence.
 

Refresh sequence

#define WDOG_FIRST_WORD_OF_REFRESH   (WDOG_REFRESH_KEY & 0xFFFFU)
 First word of refresh sequence.
 
#define WDOG_SECOND_WORD_OF_REFRESH   ((WDOG_REFRESH_KEY >> 16U) & 0xFFFFU)
 Second word of refresh sequence.
 

Driver version

#define FSL_WDOG32_DRIVER_VERSION   (MAKE_VERSION(2, 0, 4))
 WDOG32 driver version. More...
 

WDOG32 Initialization and De-initialization

void WDOG32_GetDefaultConfig (wdog32_config_t *config)
 Initializes the WDOG32 configuration structure. More...
 
void WDOG32_Init (WDOG_Type *base, const wdog32_config_t *config)
 Initializes the WDOG32 module. More...
 
void WDOG32_Deinit (WDOG_Type *base)
 De-initializes the WDOG32 module. More...
 

WDOG32 functional Operation

void WDOG32_Unlock (WDOG_Type *base)
 Unlocks the WDOG32 register written. More...
 
void WDOG32_Enable (WDOG_Type *base)
 Enables the WDOG32 module. More...
 
void WDOG32_Disable (WDOG_Type *base)
 Disables the WDOG32 module. More...
 
void WDOG32_EnableInterrupts (WDOG_Type *base, uint32_t mask)
 Enables the WDOG32 interrupt. More...
 
void WDOG32_DisableInterrupts (WDOG_Type *base, uint32_t mask)
 Disables the WDOG32 interrupt. More...
 
static uint32_t WDOG32_GetStatusFlags (WDOG_Type *base)
 Gets the WDOG32 all status flags. More...
 
void WDOG32_ClearStatusFlags (WDOG_Type *base, uint32_t mask)
 Clears the WDOG32 flag. More...
 
void WDOG32_SetTimeoutValue (WDOG_Type *base, uint16_t timeoutCount)
 Sets the WDOG32 timeout value. More...
 
void WDOG32_SetWindowValue (WDOG_Type *base, uint16_t windowValue)
 Sets the WDOG32 window value. More...
 
static void WDOG32_Refresh (WDOG_Type *base)
 Refreshes the WDOG32 timer. More...
 
static uint16_t WDOG32_GetCounterValue (WDOG_Type *base)
 Gets the WDOG32 counter value. More...
 

Data Structure Documentation

struct wdog32_work_mode_t

Data Fields

bool enableWait
 Enables or disables WDOG32 in wait mode.
 
bool enableStop
 Enables or disables WDOG32 in stop mode.
 
bool enableDebug
 Enables or disables WDOG32 in debug mode.
 
struct wdog32_config_t

Data Fields

bool enableWdog32
 Enables or disables WDOG32.
 
wdog32_clock_source_t clockSource
 Clock source select.
 
wdog32_clock_prescaler_t prescaler
 Clock prescaler value.
 
wdog32_work_mode_t workMode
 Configures WDOG32 work mode in debug stop and wait mode.
 
wdog32_test_mode_t testMode
 Configures WDOG32 test mode.
 
bool enableUpdate
 Update write-once register enable.
 
bool enableInterrupt
 Enables or disables WDOG32 interrupt.
 
bool enableWindowMode
 Enables or disables WDOG32 window mode.
 
uint16_t windowValue
 Window value.
 
uint16_t timeoutValue
 Timeout value.
 

Macro Definition Documentation

#define FSL_WDOG32_DRIVER_VERSION   (MAKE_VERSION(2, 0, 4))

Enumeration Type Documentation

Enumerator
kWDOG32_ClockSource0 

Clock source 0.

kWDOG32_ClockSource1 

Clock source 1.

kWDOG32_ClockSource2 

Clock source 2.

kWDOG32_ClockSource3 

Clock source 3.

Enumerator
kWDOG32_ClockPrescalerDivide1 

Divided by 1.

kWDOG32_ClockPrescalerDivide256 

Divided by 256.

Enumerator
kWDOG32_TestModeDisabled 

Test Mode disabled.

kWDOG32_UserModeEnabled 

User Mode enabled.

kWDOG32_LowByteTest 

Test Mode enabled, only low byte is used.

kWDOG32_HighByteTest 

Test Mode enabled, only high byte is used.

This structure contains the settings for all of the WDOG32 interrupt configurations.

Enumerator
kWDOG32_InterruptEnable 

Interrupt is generated before forcing a reset.

This structure contains the WDOG32 status flags for use in the WDOG32 functions.

Enumerator
kWDOG32_RunningFlag 

Running flag, set when WDOG32 is enabled.

kWDOG32_InterruptFlag 

Interrupt flag, set when interrupt occurs.

Function Documentation

void WDOG32_GetDefaultConfig ( wdog32_config_t config)

This function initializes the WDOG32 configuration structure to default values. The default values are:

* wdog32Config->enableWdog32 = true;
* wdog32Config->clockSource = kWDOG32_ClockSource1;
* wdog32Config->prescaler = kWDOG32_ClockPrescalerDivide1;
* wdog32Config->workMode.enableWait = true;
* wdog32Config->workMode.enableStop = false;
* wdog32Config->workMode.enableDebug = false;
* wdog32Config->testMode = kWDOG32_TestModeDisabled;
* wdog32Config->enableUpdate = true;
* wdog32Config->enableInterrupt = false;
* wdog32Config->enableWindowMode = false;
* wdog32Config->windowValue = 0U;
* wdog32Config->timeoutValue = 0xFFFFU;
*
Parameters
configPointer to the WDOG32 configuration structure.
See Also
wdog32_config_t
void WDOG32_Init ( WDOG_Type *  base,
const wdog32_config_t config 
)

This function initializes the WDOG32. To reconfigure the WDOG32 without forcing a reset first, enableUpdate must be set to true in the configuration.

Example:

* wdog32_config_t config;
* config.timeoutValue = 0x7ffU;
* config.enableUpdate = true;
* WDOG32_Init(wdog_base,&config);
*
Parameters
baseWDOG32 peripheral base address.
configThe configuration of the WDOG32.
void WDOG32_Deinit ( WDOG_Type *  base)

This function shuts down the WDOG32. Ensure that the WDOG_CS.UPDATE is 1, which means that the register update is enabled.

Parameters
baseWDOG32 peripheral base address.
void WDOG32_Unlock ( WDOG_Type *  base)

This function unlocks the WDOG32 register written.

Before starting the unlock sequence and following the configuration, disable the global interrupts. Otherwise, an interrupt could effectively invalidate the unlock sequence and the WCT may expire. After the configuration finishes, re-enable the global interrupts.

Parameters
baseWDOG32 peripheral base address
void WDOG32_Enable ( WDOG_Type *  base)

This function writes a value into the WDOG_CS register to enable the WDOG32. The WDOG_CS register is a write-once register. Please check the enableUpdate is set to true for calling WDOG32_Init to do wdog initialize. Before call the re-configuration APIs, ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters
baseWDOG32 peripheral base address.
void WDOG32_Disable ( WDOG_Type *  base)

This function writes a value into the WDOG_CS register to disable the WDOG32. The WDOG_CS register is a write-once register. Please check the enableUpdate is set to true for calling WDOG32_Init to do wdog initialize. Before call the re-configuration APIs, ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters
baseWDOG32 peripheral base address
void WDOG32_EnableInterrupts ( WDOG_Type *  base,
uint32_t  mask 
)

This function writes a value into the WDOG_CS register to enable the WDOG32 interrupt. The WDOG_CS register is a write-once register. Please check the enableUpdate is set to true for calling WDOG32_Init to do wdog initialize. Before call the re-configuration APIs, ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters
baseWDOG32 peripheral base address.
maskThe interrupts to enable. The parameter can be a combination of the following source if defined:
  • kWDOG32_InterruptEnable
void WDOG32_DisableInterrupts ( WDOG_Type *  base,
uint32_t  mask 
)

This function writes a value into the WDOG_CS register to disable the WDOG32 interrupt. The WDOG_CS register is a write-once register. Please check the enableUpdate is set to true for calling WDOG32_Init to do wdog initialize. Before call the re-configuration APIs, ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters
baseWDOG32 peripheral base address.
maskThe interrupts to disabled. The parameter can be a combination of the following source if defined:
  • kWDOG32_InterruptEnable
static uint32_t WDOG32_GetStatusFlags ( WDOG_Type *  base)
inlinestatic

This function gets all status flags.

Example to get the running flag:

* uint32_t status;
*
Parameters
baseWDOG32 peripheral base address
Returns
State of the status flag: asserted (true) or not-asserted (false).
See Also
_wdog32_status_flags_t
  • true: related status flag has been set.
  • false: related status flag is not set.
void WDOG32_ClearStatusFlags ( WDOG_Type *  base,
uint32_t  mask 
)

This function clears the WDOG32 status flag.

Example to clear an interrupt flag:

Parameters
baseWDOG32 peripheral base address.
maskThe status flags to clear. The parameter can be any combination of the following values:
  • kWDOG32_InterruptFlag
void WDOG32_SetTimeoutValue ( WDOG_Type *  base,
uint16_t  timeoutCount 
)

This function writes a timeout value into the WDOG_TOVAL register. The WDOG_TOVAL register is a write-once register. To ensure the reconfiguration fits the timing of WCT, unlock function will be called inline.

Parameters
baseWDOG32 peripheral base address
timeoutCountWDOG32 timeout value, count of WDOG32 clock ticks.
void WDOG32_SetWindowValue ( WDOG_Type *  base,
uint16_t  windowValue 
)

This function writes a window value into the WDOG_WIN register. The WDOG_WIN register is a write-once register. Please check the enableUpdate is set to true for calling WDOG32_Init to do wdog initialize. Before call the re-configuration APIs, ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters
baseWDOG32 peripheral base address.
windowValueWDOG32 window value.
static void WDOG32_Refresh ( WDOG_Type *  base)
inlinestatic

This function feeds the WDOG32. This function should be called before the Watchdog timer is in timeout. Otherwise, a reset is asserted.

Parameters
baseWDOG32 peripheral base address
static uint16_t WDOG32_GetCounterValue ( WDOG_Type *  base)
inlinestatic

This function gets the WDOG32 counter value.

Parameters
baseWDOG32 peripheral base address.
Returns
Current WDOG32 counter value.