PSoC 6 Peripheral Driver Library
MCWDT (Multi-Counter Watchdog)

General Description

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.

Configuration Considerations

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:

mcwdt.png

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.

mcwdt_counters.png

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.

mcwdt_subcounters.png

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().

Note
In addition to the MCWDTs, each device has a separate watchdog timer (WDT) that can also be used to generate a watchdog reset or periodic interrupts. For more information on the WDT, see the appropriate section of the PDL.

More Information

For more information on the MCWDT peripheral, refer to the technical reference manual (TRM).

MISRA-C Compliance

The mcwdt driver does not have any specific deviations.

Changelog

VersionChangesReason for Change
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