CAT2 Peripheral Driver Library

Functions

void Cy_WDT_Init (void)
 Initializes the Watchdog timer to its default state: More...
 
__STATIC_INLINE void Cy_WDT_Enable (void)
 Enables watchdog timer reset generation. More...
 
__STATIC_INLINE bool Cy_WDT_IsEnabled (void)
 Returns the WDT enable/disable state. More...
 
__STATIC_INLINE void Cy_WDT_Disable (void)
 Disables the WDT reset generation. More...
 
__STATIC_INLINE uint32_t Cy_WDT_GetCount (void)
 Reads the current WDT counter value. More...
 
void Cy_WDT_SetMatch (uint32_t match)
 Configures the WDT counter match comparison value. More...
 
__STATIC_INLINE uint32_t Cy_WDT_GetMatch (void)
 Reads the WDT counter match comparison value. More...
 
void Cy_WDT_SetIgnoreBits (uint32_t bitsNum)
 Configures the number of the most significant bits of the Watchdog timer that are not checked against the match. More...
 
__STATIC_INLINE uint32_t Cy_WDT_GetIgnoreBits (void)
 Reads the number of the most significant bits of the Watchdog timer that are not checked against the match. More...
 
__STATIC_INLINE void Cy_WDT_MaskInterrupt (void)
 After masking interrupts from the WDT, they are not passed to the CPU. More...
 
__STATIC_INLINE void Cy_WDT_UnmaskInterrupt (void)
 After unmasking interrupts from the WDT, they are passed to CPU. More...
 
__STATIC_INLINE bool Cy_WDT_GetInterruptStatusMasked (void)
 Returns an interrupt request register masked by an interrupt mask. More...
 
void Cy_WDT_ClearInterrupt (void)
 Clears the WDT interrupt request which is set as configured by WDT action and limits.
 
__STATIC_INLINE void Cy_WDT_ClearWatchdog (void)
 Clears ("feeds") the watchdog, to prevent a XRES device reset. More...
 
__STATIC_INLINE void Cy_WDT_Lock (void)
 Locks out configuration changes to the Watchdog Timer register. More...
 
__STATIC_INLINE void Cy_WDT_Unlock (void)
 Unlocks the Watchdog Timer configuration register. More...
 
__STATIC_INLINE bool Cy_WDT_Locked (void)
 Returns the WDT lock state. More...
 
__STATIC_INLINE void Cy_WDT_SetLowerLimit (uint32_t match)
 Set lower limit for watchdog. More...
 
__STATIC_INLINE void Cy_WDT_SetUpperLimit (uint32_t match)
 Set upper limit for watchdog. More...
 
__STATIC_INLINE void Cy_WDT_SetWarnLimit (uint32_t match)
 Set warn limit for watchdog. More...
 
__STATIC_INLINE void Cy_WDT_SetLowerAction (cy_en_wdt_lower_upper_action_t action)
 Set action taken if this watchdog is serviced before LOWER_LIMIT is reached. More...
 
__STATIC_INLINE void Cy_WDT_SetUpperAction (cy_en_wdt_lower_upper_action_t action)
 Set action taken if this watchdog is not serviced before UPPER_LIMIT is reached. More...
 
__STATIC_INLINE void Cy_WDT_SetWarnAction (cy_en_wdt_warn_action_t action)
 Set action taken when the count value reaches WARN_LIMIT. More...
 
__STATIC_INLINE void Cy_WDT_SetAutoService (cy_en_wdt_enable_t enable)
 Set automatically service when the count value reaches WARN_LIMIT. More...
 
__STATIC_INLINE void Cy_WDT_SetDeepSleepPause (cy_en_wdt_enable_t enable)
 Set whether the WDT counter runs/pauses when the system is in DEEPSLEEP. More...
 
__STATIC_INLINE void Cy_WDT_SetDebugRun (cy_en_wdt_enable_t enable)
 Set the debug run value. More...
 
__STATIC_INLINE void Cy_WDT_SetService (void)
 Set service of the watchdog. More...
 
__STATIC_INLINE void Cy_WDT_SetCount (uint32_t count)
 Set the WDT counter value. More...
 
__STATIC_INLINE void Cy_WDT_SetInterrupt (void)
 Triggers an interrupt with software. More...
 

Detailed Description

Function Documentation

◆ Cy_WDT_Init()

void Cy_WDT_Init ( void  )

Initializes the Watchdog timer to its default state:

  • WDT disabled
  • WDT match value is 4096
  • None of ignore bits are set: the whole WDT counter bits are checked against the match value.

This function clears the WDT interrupt.

For PSOC4 HVMS/PA devices the given default setting of the WDT:

  • The WDT is unlocked and disabled.
  • The WDT Lower Limit value is set to 0 and Lower action to None.
  • The WDT Warn Limit value is set to 0 and Warn action to None.
  • The WDT Upper Limit value is set to 32768 (~1 sec when clk_lf = 32KHz) and Upper action to Reset.
  • The WDT is locked again.

◆ Cy_WDT_Enable()

__STATIC_INLINE void Cy_WDT_Enable ( void  )

Enables watchdog timer reset generation.

Warning
For PSOC4 HVMS/PA the Watchdog timer should be unlocked before being enabled. Call the Cy_WDT_Unlock() API to unlock the WDT.
Note
May take up to three Low-Frequency Clock cycles to take effect. Do not enter DeepSleep if the WDT enabling doesn't take effect. It can be done by waiting until Cy_WDT_IsEnabled() returns true.
Function Usage
if(false == Cy_WDT_Locked())
{
while(!Cy_WDT_IsEnabled())
{
/* Do nothing. Wait until the WDT Enable takes effect.
May take up to three clk_lf cycles to take effect. */
}
}

◆ Cy_WDT_IsEnabled()

__STATIC_INLINE bool Cy_WDT_IsEnabled ( void  )

Returns the WDT enable/disable state.

Returns
The WDT state.
  • true : Counter is enabled (counting up).
  • false : Counter is disabled (not clocked).
Function Usage
if(false == Cy_WDT_Locked())
{
while(!Cy_WDT_IsEnabled())
{
/* Do nothing. Wait until the WDT Enable takes effect.
May take up to three clk_lf cycles to take effect. */
}
}

◆ Cy_WDT_Disable()

__STATIC_INLINE void Cy_WDT_Disable ( void  )

Disables the WDT reset generation.

Warning
For PSOC4 HVMS/PA the Watchdog timer should be unlocked before being disabled. Call the Cy_WDT_Unlock() API to unlock the WDT.
Note
When disable the WDT, the counter is cleared.
May take up to three Low-Frequency Clock cycles to take effect. It can be done by waiting until Cy_WDT_IsEnabled() returns false.
Function Usage
{
{
/* Do nothing. Wait until the WDT Disable takes effect.
May take up to three clk_lf cycles to take effect. */
}
}

◆ Cy_WDT_GetCount()

__STATIC_INLINE uint32_t Cy_WDT_GetCount ( void  )

Reads the current WDT counter value.

Returns
A live counter value.

◆ Cy_WDT_SetMatch()

void Cy_WDT_SetMatch ( uint32_t  match)

Configures the WDT counter match comparison value.

Parameters
matchThe valid range is [0-65535]. The value to be used to match against the counter.
Note
Not applicable for PSOC4 HVMS/PA.

◆ Cy_WDT_GetMatch()

__STATIC_INLINE uint32_t Cy_WDT_GetMatch ( void  )

Reads the WDT counter match comparison value.

Returns
The counter match value.
Note
Not applicable for PSOC4 HVMS/PA.

◆ Cy_WDT_SetIgnoreBits()

void Cy_WDT_SetIgnoreBits ( uint32_t  bitsNum)

Configures the number of the most significant bits of the Watchdog timer that are not checked against the match.

Parameters
bitsNumThe number of the most significant bits. The valid range is [0-15].

The value of bitsNum controls the time-to-reset of the Watchdog timer. This happens after 3 successive matches.

Note
Certain products may enforce a minimum value for this register through design time configuration.
Warning
This function changes the WDT interrupt period, therefore the device can go into an infinite WDT reset loop. This may happen if a WDT reset occurs faster that a device start-up.
Note
Not applicable for PSOC4 HVMS/PA.

◆ Cy_WDT_GetIgnoreBits()

__STATIC_INLINE uint32_t Cy_WDT_GetIgnoreBits ( void  )

Reads the number of the most significant bits of the Watchdog timer that are not checked against the match.

Returns
The number of the most significant bits.
Note
Not applicable for PSOC4 HVMS/PA.

◆ Cy_WDT_MaskInterrupt()

__STATIC_INLINE void Cy_WDT_MaskInterrupt ( void  )

After masking interrupts from the WDT, they are not passed to the CPU.

This function does not disable the WDT-reset generation.

◆ Cy_WDT_UnmaskInterrupt()

__STATIC_INLINE void Cy_WDT_UnmaskInterrupt ( void  )

After unmasking interrupts from the WDT, they are passed to CPU.

This function does not impact the reset generation.

◆ Cy_WDT_GetInterruptStatusMasked()

__STATIC_INLINE bool Cy_WDT_GetInterruptStatusMasked ( void  )

Returns an interrupt request register masked by an interrupt mask.

Returns the result of the bitwise AND operation between the corresponding interrupt request and mask bits.

Returns
The masked interrupt status.
  • true : Masked interrupt occurs.
  • false : No Masked interrupt occurs.
Note
For PSOC4 HVMS/PA, due to internal synchronization, it takes up to 8 SYSCLK cycles to read from this register and during this time AHB bus is stalled.

◆ Cy_WDT_ClearWatchdog()

__STATIC_INLINE void Cy_WDT_ClearWatchdog ( void  )

Clears ("feeds") the watchdog, to prevent a XRES device reset.

This function simply call Cy_WDT_ClearInterrupt() function.

◆ Cy_WDT_Lock()

__STATIC_INLINE void Cy_WDT_Lock ( void  )

Locks out configuration changes to the Watchdog Timer register.

After this function is called, the WDT configuration cannot be changed until Cy_WDT_Unlock() is called.

Warning
The WDT lock state is not retained during system Deep Sleep. After the wakeup from system Deep Sleep the WDT is locked.
Note
Applicable to PSOC4 HVMS/PA only.
Function Usage
{
}

◆ Cy_WDT_Unlock()

__STATIC_INLINE void Cy_WDT_Unlock ( void  )

Unlocks the Watchdog Timer configuration register.

The Watchdog timer should be unlocked before:

  • ILO being enabled/disabled
  • PILO being enabled/disabled
  • the LFCLK source being changed
  • WDT being reconfigured
Warning
The WDT lock state is not retained during system Deep Sleep. After the wakeup from system Deep Sleep the WDT is locked.
Note
Applicable to PSOC4 HVMS/PA only.
Function Usage

◆ Cy_WDT_Locked()

__STATIC_INLINE bool Cy_WDT_Locked ( void  )

Returns the WDT lock state.

Returns
The WDT lock state.
  • true : if WDT is locked.
  • false : if WDT is unlocked.
Warning
The WDT lock state is not retained during system Deep Sleep. After the wakeup from system Deep Sleep the WDT is locked.
Note
Applicable to PSOC4 HVMS/PA only.
Function Usage

◆ Cy_WDT_SetLowerLimit()

__STATIC_INLINE void Cy_WDT_SetLowerLimit ( uint32_t  match)

Set lower limit for watchdog.

Parameters
match- Value to be matched
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.
Function Usage
Use case 3. The WDT counter in interrupt mode.

◆ Cy_WDT_SetUpperLimit()

__STATIC_INLINE void Cy_WDT_SetUpperLimit ( uint32_t  match)

Set upper limit for watchdog.

Parameters
match- Value to be matched
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.
Function Usage
Use case 3. The WDT counter in interrupt mode.

◆ Cy_WDT_SetWarnLimit()

__STATIC_INLINE void Cy_WDT_SetWarnLimit ( uint32_t  match)

Set warn limit for watchdog.

Parameters
match- Value to be matched
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.
Function Usage
Use case 3. The WDT counter in interrupt mode.

◆ Cy_WDT_SetLowerAction()

__STATIC_INLINE void Cy_WDT_SetLowerAction ( cy_en_wdt_lower_upper_action_t  action)

Set action taken if this watchdog is serviced before LOWER_LIMIT is reached.

Parameters
actioncy_en_wdt_lower_upper_action_t
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.
Function Usage
Use case 3. The WDT counter in interrupt mode.

◆ Cy_WDT_SetUpperAction()

__STATIC_INLINE void Cy_WDT_SetUpperAction ( cy_en_wdt_lower_upper_action_t  action)

Set action taken if this watchdog is not serviced before UPPER_LIMIT is reached.

Parameters
actioncy_en_wdt_lower_upper_action_t
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.
Function Usage
Use case 3. The WDT counter in interrupt mode.

◆ Cy_WDT_SetWarnAction()

__STATIC_INLINE void Cy_WDT_SetWarnAction ( cy_en_wdt_warn_action_t  action)

Set action taken when the count value reaches WARN_LIMIT.

Parameters
actioncy_en_wdt_warn_action_t
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.
Function Usage
Use case 3. The WDT counter in interrupt mode.

◆ Cy_WDT_SetAutoService()

__STATIC_INLINE void Cy_WDT_SetAutoService ( cy_en_wdt_enable_t  enable)

Set automatically service when the count value reaches WARN_LIMIT.

This function is used for WARN_LIMIT. This allows creation of a periodic interrupt if this counter is not needed as a watchdog. This configuration is ignored when LOWER_ACTION or when UPPER_ACTION is set to trigger a reset.

Parameters
enablecy_en_wdt_enable_t
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.
Function Usage
Use case 3. The WDT counter in interrupt mode.

◆ Cy_WDT_SetDeepSleepPause()

__STATIC_INLINE void Cy_WDT_SetDeepSleepPause ( cy_en_wdt_enable_t  enable)

Set whether the WDT counter runs/pauses when the system is in DEEPSLEEP.

Parameters
enablecy_en_wdt_enable_t
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.

◆ Cy_WDT_SetDebugRun()

__STATIC_INLINE void Cy_WDT_SetDebugRun ( cy_en_wdt_enable_t  enable)

Set the debug run value.

It needs when using debugger.

Parameters
enablecy_en_wdt_enable_t
Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.

◆ Cy_WDT_SetService()

__STATIC_INLINE void Cy_WDT_SetService ( void  )

Set service of the watchdog.

This resets the count value to zero. If WDT is disabled, service will not trigger a LOWER_ACTION and will not clear a preloaded count value.

Note
Applicable to PSOC4 HVMS/PA only.
May take up to three Low-Frequency Clock cycles to take effect.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.

◆ Cy_WDT_SetCount()

__STATIC_INLINE void Cy_WDT_SetCount ( uint32_t  count)

Set the WDT counter value.

When WDT is disabled and unlocked, the count value can be written for verification and debugging purposes. Software writes are always ignored when the WDT is enabled. Set the WDT counter value may lag the actual count value by up to one Low-Frequency Clock cycle, due to internal synchronization.

Note
Applicable to PSOC4 HVMS/PA only.
Warning
The Watchdog timer should be unlocked and disabled before being configured. Call the Cy_WDT_Unlock() API to unlock the WDT.

◆ Cy_WDT_SetInterrupt()

__STATIC_INLINE void Cy_WDT_SetInterrupt ( void  )

Triggers an interrupt with software.

Can be used to set interrupts for firmware testing.

Note
Applicable to PSOC4 HVMS/PA only.
Due to internal synchronization, it takes up to 8 System Clock cycles to update after a W1S or reading from this register and during this time AHB bus is stalled.