Skip to content

Infineon/mtb-hv-example-psoc4-wdt-interrupt-reset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSoC™ 4: Watchdog timer interrupt and reset

This example demonstrates how watchdog timer works with the interrupt mode and the reset mode.

Device

The device used in this code example (CE) is:

Board

The board used for testing is:

Scope of work

This code example deals with the watchdog timer (WDT) of PSoC™ 4. The WDT operates in two modes: the interrupt mode and the reset mode. In the interrupt mode, the LED toggles every second. If it's configured as the reset mode, the LED blinks thrice with an interval of 200 milliseconds each time the watchdog reset occurs.

Introduction

The WDTs are used to automatically reset the device in the event of an unexpected firmware execution path. They are also used as a wakeup source to periodically generate interrupts as a wakeup source in low-power modes. There are several WDT functionalities in PSoC™ 4 HVMS devices. These are:

  • Basic WDT
  • Challenge-response WDT (CRWDT)
  • Lifetime counter with wakeup capability.

The basic WDT is a free-running up-counter with programmable limit values and a maximum resolution of 32 bits, as featured in this code example.

  • 32-bit counter and compares, clocked by LFCLK
  • Lower, Warn, and Upper limits with programmable actions for each
  • Implemented in VCCD logic domain

More details can be found in:

Hardware setup

This Code Example has been developed for:

Figure 1. KIT_PSoC4-HVMS-128K_LITE (Top View)

Implementation

The firmware is implemented in main.c and performs the following functions:

  1. Enable WDT interrupt
  2. Initialize and start WDT
  3. LED6 toggles every second if it's the interrupt mode
  4. LED6 blinks thrice each time the reset occurs if it's the reset mode

You can change the interrupt mode/the reset mode by changing the macro

Figure 2. The macro to change the mode


ModusToolbox™ Device configurator

This code example project can be created or imported using ModusToolbox™ IDE. To configure the project in the Quick Panel, click on Device Configurator. You can configure peripheral and clock settings on Device Configurator. You can see Watchdog Timer (WDT) clock is from LFCLK on Clock System.

Figure 3. Select Device Configurator

Figure 4. Device Configurator

Figure 5. Clock System


PDL functions

Compiling and programming

Before testing this code example:

  • Power the board through the dedicated power connector
  • Connect the board to the PC through the USB interface
  • Build the project using the dedicated Build button

Figure 6. Build Project

or by right-clicking the project name and selecting "Build Project"

  • To program the board, in the Quick Panel, scroll down, and click [Project Name] Program (KitProg3_MiniProg4)

Run and Test

  • After programming, the code example will start automatically and you can see

  • The LED6 toggles every second in the interrupt mode

  • The LED6 blinks thrice with an interval of 200 milliseconds each time the watchdog reset occurs in the reset mode

  • You can debug the example to step through the code. In the IDE, use the [Project Name] Debug (KitProg3_MiniProg4) configuration in the Quick Panel. For details, see the "Program and debug" section in the Eclipse IDE for Toolbox™ software user guide.

Note: (Only while debugging) On the CM7 CPU, some code in main() may execute before the debugger halts at the beginning of main(). This means that some code executes twice: once before the debugger stops execution, and again after the debugger resets the program counter to the beginning of main(). See KBA231071 to learn about this and for the workaround.

References

Relevant Application notes are:

  • AN0034 - Getting started with PSOC™ 4 HV MS MCUs in ModusToolbox™

ModusToolbox™ is available online:

Associated PSoC™ 4 HVMS MCUs can be found on:

More code examples can be found on the GIT repository:

For additional trainings, visit our webpage:

For questions and support, use the PSoC™ 4 HVMS Forum: