A MCWDT has two 16-bit counters and one 32-bit counter.
The functions and other declarations used in this driver are in cy_mcwdt.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.
You can use this driver to create a free-running timer or generate periodic interrupts. The driver also includes support for the watchdog function to recover from CPU or firmware failures.
There are two primary use cases for MCWDT: generating periodic CPU interrupts; and implementing a free-running timer. Both have many applications in embedded systems:
An additional use case is to implement a watchdog used for recovering from a CPU or firmware failure.
Each MCWDT may be configured for a particular product. One MCWDT block can be associated with only one CPU during runtime. A single MCWDT is not intended to be used by multiple CPUs simultaneously. Each block contains three sub-counters, each of which can be configured for various system utility functions - free running counter, periodic interrupts, watchdog reset, or three interrupts followed by a watchdog reset. All counters are clocked by either LFCLK (nominal 32 kHz) or by a cascaded counter. A simplified diagram of the MCWDT hardware is shown below:
The frequency of the periodic interrupts can be configured using the Match value with combining Clear on match option, which can be set individually for each counter using Cy_MCWDT_SetClearOnMatch(). When the Clear on match option is not set, the periodic interrupts of the C0 and C1 16-bit sub-counters occur after 65535 counts and the match value defines the shift between interrupts (see the figure below). The enabled Clear on match option resets the counter when the interrupt occurs.
32-bit sub-counter C2 does not have Clear on match option. The interrupt of counter C2 occurs when the counts equal 2Toggle bit value.
To set up an MCWDT, provide the configuration parameters in the cy_stc_mcwdt_config_t structure. Then call Cy_MCWDT_Init() to initialize the driver. Call Cy_MCWDT_Enable() to enable all specified counters.
You can also set the mode of operation for any counter. If you choose interrupt mode, use Cy_MCWDT_SetInterruptMask() with the parameter for the masks described in Macro Section. All counter interrupts are OR'd together to from a single combined MCWDT interrupt. Additionally, enable the Global interrupts and initialize the referenced interrupt by setting the priority and the interrupt vector using Cy_SysInt_Init() of the sysint driver.
The values of the MCWDT counters can be monitored using Cy_MCWDT_GetCount().
CAT1C and TVIIBE devices support MCWDT_B type of counters, which are slightly different from MCWDT, which is explained above
A simplified diagram of the MCWDT_B hardware is shown below:
For more information on the MCWDT peripheral, refer to the technical reference manual (TRM).
Version | Changes | Reason for Change |
---|---|---|
1.80 | Added support for TRAVEO™ II Body Entry devices. Pre-processor check for MXS40SRSS version now groups ver. 2 with ver. 3. Previously ver. 2 was grouped with ver. 1. | Code enhancement and support for new devices. |
1.70 | Added MCWDT_B type support required for CAT1C devices. Newly added APIs: Cy_MCWDT_SetLowerAction(), Cy_MCWDT_SetUpperAction(), Cy_MCWDT_SetWarnAction(), Cy_MCWDT_SetSubCounter2Action(), Cy_MCWDT_GetLowerAction(), Cy_MCWDT_GetUpperAction(), Cy_MCWDT_GetWarnAction(), Cy_MCWDT_GetSubCounter2Action(), Cy_MCWDT_SetAutoService(), Cy_MCWDT_GetAutoService(), Cy_MCWDT_SetSleepDeepPause(), Cy_MCWDT_GetSleepDeepPause(), Cy_MCWDT_SetDebugRun(), Cy_MCWDT_GetDebugRun(), Cy_MCWDT_SetLowerLimit(), Cy_MCWDT_SetUpperLimit(), Cy_MCWDT_SetWarnLimit(), Cy_MCWDT_GetLowerLimit(), Cy_MCWDT_GetUpperLimit(), Cy_MCWDT_GetWarnLimit(), Cy_MCWDT_WaitForCounterReset(), Cy_MCWDT_CpuSelectForDpSlpPauseAction(), Cy_MCWDT_GetCascadeMatchCombined(). | Support for new devices. |
1.60 | CAT1B, CAT1C devices support. Newly added APIs: Cy_MCWDT_GetLowerLimit() to get the lower limit value of the specified counter, Cy_MCWDT_SetLowerLimit() to set the the lower limit value of the specified counter, Cy_MCWDT_GetLowerLimitMode() to get the lower limit mode of the specified counter, Cy_MCWDT_SetLowerLimitMode() to set the lower limit mode of the specified counter, Cy_MCWDT_GetLowerLimitCascaded() to get the lower limit registers cascaded value, Cy_MCWDT_SetCascadeCarryOutRollOver() to enable the Rollover mode for carryout, Cy_MCWDT_GetCascadeCarryOutRollOver() to check if Rollover mode enabled for carryout or not, Cy_MCWDT_SetCascadeMatchCombined() to set the match to combined cascade counters, Cy_MCWDT_GetCascadeMatchCombined() to report if match is enabled with combined cascade counters or not. | Support for new devices. |
1.50.1 | Minor documentation updates. | Documentation enhancement. |
1.50 | Added support for new family of devices. | New device support. |
1.40 | Fixed/documented MISRA 2012 violations. | MISRA 2012 compliance. |
1.30.1 | Minor documentation updates. | Documentation enhancement. |
1.30 | In version 1.20 the Cy_MCWDT_GetCountCascaded() function returned the wrong value when counter#1 overflowed. This bug is corrected in version 1.30. | Defect fixes. |
1.20 | Flattened the organization of the driver source code into the single source directory and the single include directory. | Driver library directory-structure simplification. |
Added register access layer. Use register access macros instead of direct register access using dereferenced pointers. | Makes register access device-independent, so that the PDL does not need to be recompiled for each supported part number. | |
1.10.1 | Updated description of the cy_stc_mcwdt_config_t structure type | Documentation update and clarification |
1.10 | Added input parameter validation to the API functions. Added API function GetCountCascaded() | |
1.0 | Initial version |
API Reference | |
Macros | |
Functions | |
Data Structures | |
Enumerated Types | |