diff --git a/.gitignore b/.gitignore index 96b395d..a053ead 100644 --- a/.gitignore +++ b/.gitignore @@ -1,145 +1,148 @@ -# This list of files to ignore includes common, tool- or user-specific files that -# are typically not checked into a version control system (VCS). It is a superset -# of such files. You may want to add others, especially if you use a tool not listed -# here. You can remove those that do not apply to you. -# -# The .gitignore file is intended for the git VCS. For another VCS you would specify -# which files to ignore in whatever form your VCS requires. If you do not check your -# code into a VCS, you can ignore the .gitignore file. - -# ModusToolbox Libraries -libs/* -!libs/*.lib - -# Eclipse IDE for ModusToolbox files -.metadata/ -.cyignore -# .settings/ -# .cproject -# .project -# .mtbLaunchConfigs/ - -# Eclipse IDE for ModusToolbox build output -build/ -Debug/ -Release/ -*_build/ - -# Visual Studio Code -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# IAR Embedded Workbench files - -# IAR Project file. -# *.ewp - -# IAR Settings -/settings/ - -# Uncomment this if not using project connections -# *.ipcf - -# Comment this out if using custom argument variables -*.custom_argvars - -# IAR Debugger Settings -# *.ewd - -# Comment this out if you use C-Stat or C-Run to compile/analyze your project -*.ewt - -# IAR Workspace files -# *.eww - -# IAR Debug Exe -/Debug/Exe/ - -# IAR Debug List -/Debug/List - -# IAR Debug Obj -/Obj/*.pbd -/Obj/*.pbd.* -/Obj/*.pbi -/Obj/*.pbi.* - -# Log files -*.log - -# IAR backup files -Backup* - -# IAR dependency files -*.dep - -# Compiled Binaries -*.bin -*.elf -*.hex -*.map - -# Trash files -*.bak - - -# Keil uVision files - -# Project and package description files -*.cpdsc -*.gpdsc - -# uVision Project file (generated by uVision). Uncomment this if do not want to track the Keil uVision project file -# *.uvprojx (is used to build the project from scratch) - -# Project options file (contains information about the debugger and trace configuration) -# *.uvoptx - -# Project file for multi-project workspaces -# *.uvmpw - -# Project screen layout file -*.uvguix.* - -# Configuration files for the run-time environment -# RTE/ - -# Generated output files -*.lst -*.map - -# Eclipse workspace/user-specific files/settings/caches -.metadata/ -# .settings/ - -# Vi and Emacs backup files -*~ -\#*\# -[._]*.s[a-v][a-z] -[._]*.sw[a-p] -[._]s[a-rt-v][a-z] -[._]ss[a-gi-z] -[._]sw[a-p] - -# Created by git when using merge tools for conflicts -*.BACKUP.* -*.BASE.* -*.LOCAL.* -*.REMOTE.* -*_BACKUP_*.txt -*_BASE_*.txt -*_LOCAL_*.txt -*_REMOTE_*.txt - -# macOS Finder incidental files -.DS_Store - -# Windows Explorer incidental files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db -[Dd]esktop.ini +# This list of files to ignore includes common, tool- or user-specific files that +# are typically not checked into a version control system (VCS). It is a superset +# of such files. You may want to add others, especially if you use a tool not listed +# here. You can remove those that do not apply to you. +# +# The .gitignore file is intended for the git VCS. For another VCS you would specify +# which files to ignore in whatever form your VCS requires. If you do not check your +# code into a VCS, you can ignore the .gitignore file. + +# ModusToolbox library repos or information about library dependencies +libs/ + +# Eclipse IDE for ModusToolbox files +.metadata/ +# .cyignore +# .settings/ +# .cproject +# .project +# .mtbLaunchConfigs/ + +# ModusToolbox Configurator generated code +GeneratedSource/ + +# ModusToolbox build system output +build/ +Debug/ +Release/ +*_build/ + +# Visual Studio Code +openocd.tcl +.vscode/ +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# IAR Embedded Workbench files + +# IAR Project file. +# *.ewp + +# IAR Settings +/settings/ + +# Uncomment this if not using project connections +# *.ipcf + +# Comment this out if using custom argument variables +*.custom_argvars + +# IAR Debugger Settings +# *.ewd + +# Comment this out if you use C-Stat or C-Run to compile/analyze your project +*.ewt + +# IAR Workspace files +# *.eww + +# IAR Debug Exe +/Debug/Exe/ + +# IAR Debug List +/Debug/List + +# IAR Debug Obj +/Obj/*.pbd +/Obj/*.pbd.* +/Obj/*.pbi +/Obj/*.pbi.* + +# Log files +*.log + +# IAR backup files +Backup* + +# IAR dependency files +*.dep + +# Compiled Binaries +*.bin +*.elf +*.hex +*.map + +# Trash files +*.bak + + +# Keil uVision files + +# Project and package description files +*.cpdsc +*.gpdsc + +# uVision Project file (generated by uVision). Uncomment this if do not want to track the Keil uVision project file +# *.uvprojx (is used to build the project from scratch) + +# Project options file (contains information about the debugger and trace configuration) +# *.uvoptx + +# Project file for multi-project workspaces +# *.uvmpw + +# Project screen layout file +*.uvguix.* + +# Configuration files for the run-time environment +# RTE/ + +# Generated output files +*.lst +*.map + +# Eclipse workspace/user-specific files/settings/caches +.metadata/ +# .settings/ + +# Vi and Emacs backup files +*~ +\#*\# +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +# macOS Finder incidental files +.DS_Store + +# Windows Explorer incidental files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +[Dd]esktop.ini diff --git a/LICENSE b/LICENSE index 91c81ad..f7eec35 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -CYPRESS END USER LICENSE AGREEMENT +CYPRESS (AN INFINEON COMPANY) END USER LICENSE AGREEMENT PLEASE READ THIS END USER LICENSE AGREEMENT ("Agreement") CAREFULLY BEFORE DOWNLOADING, INSTALLING, COPYING, OR USING THIS SOFTWARE AND ACCOMPANYING diff --git a/Makefile b/Makefile index 0b1b925..178dd47 100644 --- a/Makefile +++ b/Makefile @@ -7,15 +7,15 @@ # ################################################################################ # \copyright -# Copyright 2018-2020 Cypress Semiconductor Corporation +# Copyright 2018-2021 Cypress Semiconductor Corporation (an Infineon company) # SPDX-License-Identifier: Apache-2.0 -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,14 +28,23 @@ # Basic Configuration ################################################################################ -# Target board/hardware +# Target board/hardware (BSP). +# To change the target, it is recommended to use the Library manager +# ('make modlibs' from command line), which will also update Eclipse IDE launch +# configurations. If TARGET is manually edited, ensure TARGET_.mtb with a +# valid URL exists in the application, run 'make getlibs' to fetch BSP contents +# and update or regenerate launch configurations for your IDE. TARGET=CY8CPROTO-062-4343W + # Name of application (used to derive name of final linked file). +# +# If APPNAME is edited, ensure to update or regenerate launch +# configurations for your IDE. APPNAME=mtb-example-psoc6-wdt # Name of toolchain to use. Options include: # -# GCC_ARM -- GCC 7.2.1, provided with ModusToolbox IDE +# GCC_ARM -- GCC provided with ModusToolbox IDE # ARM -- ARM Compiler (must be installed separately) # IAR -- IAR Compiler (must be installed separately) # @@ -44,8 +53,12 @@ TOOLCHAIN=GCC_ARM # Default build configuration. Options include: # -# Debug -- build with minimal optimizations, focus on debugging. +# Debug -- build with minimal optimizations, focus on debugging. # Release -- build with full optimizations +# Custom -- build with custom configuration, set the optimization flag in CFLAGS +# +# If CONFIG is manually edited, ensure to update or regenerate launch configurations +# for your IDE. CONFIG=Debug # If set to "true" or "1", display full command-lines when building. @@ -63,7 +76,7 @@ VERBOSE= # # COMPONENTS=foo bar # -# ... then code in directories named COMPONENT_foo and COMPONENT_bar will be +# ... then code in directories named COMPONENT_foo and COMPONENT_bar will be # added to the build # COMPONENTS= @@ -82,17 +95,9 @@ SOURCES= INCLUDES= # Add additional defines to the build process (without a leading -D). -# The below definition enables interrupt mode operation of the WDT. -# If reset mode is desired, use the definition WDT_RESET_DEMO instead for -# the WDT_DEMO -DEFINES=WDT_DEMO=WDT_INTERRUPT_DEMO -# Uncomment the below define to introduce a blocking code in the main loop -#DEFINES+=EXECUTION_BLOCK -# Uncomment the below define to put the device in deep sleep mode while using -# interrupt demo mode -#DEFINES+=DEEPSLEEP_ENABLE - -# Select softfp or hardfp floating point. Default is softfp. +DEFINES= + +# Select softfp or hardfp floating point. Default is softfp. VFP_SELECT= # Additional / custom C compiler flags. @@ -138,11 +143,20 @@ POSTBUILD= # This controls where automatic source code discovery looks for code. CY_APP_PATH= -# Relative path to the "base" library. It provides the core makefile build -# infrastructure. -CY_BASELIB_PATH=libs/psoc6make +# Relative path to the shared repo location. +# +# All .mtb files have the format, ##. If the field +# begins with $$ASSET_REPO$$, then the repo is deposited in the path specified by +# the CY_GETLIBS_SHARED_PATH variable. The default location is one directory level +# above the current app directory. +# This is used with CY_GETLIBS_SHARED_NAME variable, which specifies the directory name. +CY_GETLIBS_SHARED_PATH=../ + +# Directory name of the shared repo location. +# +CY_GETLIBS_SHARED_NAME=mtb_shared -# Absolute path to the compiler's "bin" directory. +# Absolute path to the compiler's "bin" directory. # # The default depends on the selected TOOLCHAIN (GCC_ARM uses the ModusToolbox # IDE provided compiler by default). @@ -159,7 +173,7 @@ CY_TOOLS_PATHS ?= $(wildcard \ # If you install ModusToolbox IDE in a custom location, add the path to its # "tools_X.Y" folder (where X and Y are the version number of the tools -# folder). +# folder). Make sure you use forward slashes. CY_TOOLS_PATHS+= # Default to the newest installed tools folder, or the users override (if it's @@ -167,7 +181,7 @@ CY_TOOLS_PATHS+= CY_TOOLS_DIR=$(lastword $(sort $(wildcard $(CY_TOOLS_PATHS)))) ifeq ($(CY_TOOLS_DIR),) -$(error Unable to find any of the available CY_TOOLS_PATHS -- $(CY_TOOLS_PATHS)) +$(error Unable to find any of the available CY_TOOLS_PATHS -- $(CY_TOOLS_PATHS). On Windows, use forward slashes.) endif $(info Tools Directory: $(CY_TOOLS_DIR)) diff --git a/README.md b/README.md index e12e094..bdbd323 100644 --- a/README.md +++ b/README.md @@ -1,227 +1,228 @@ -# PSoC 6 MCU Watchdog Timer - -This example explains two use cases of Watchdog Timer (WDT) – a watchdog that causes a device reset in the case of a malfunction and as a periodic interrupt source. - -A few `#defines` in the Makefile determines the mode to be used. Out of the box, this example demonstrates the periodic interrupt. The user LED toggles on every interrupt at an interval of ~1 s. - -For reset mode, change the `#define` and enable an infinite loop in the `main()` function to block the execution. The device resets in ~4 s. The user LED blinks twice after the device comes out of reset. If you use the reset mode without blocking the execution, the device does not reset. The user LED toggles every 1 s in the main loop to indicate that the CPU is in action. In addition, the user LED blinks once for power cycling or an external reset event. - -## Requirements - -- [ModusToolbox™ software](https://www.cypress.com/products/modustoolbox-software-environment) v2.1 -- Programming Language: C -- Associated Parts: All [PSoC® 6 MCU](http://www.cypress.com/PSoC6) parts - -## Supported Kits - -- [PSoC 6 Wi-Fi BT Prototyping Kit](https://www.cypress.com/CY8CPROTO-062-4343W) (CY8CPROTO-062-4343W) - Default target -- [PSoC 6 WiFi-BT Pioneer Kit](https://www.cypress.com/CY8CKIT-062-WiFi-BT) (CY8CKIT-062-WiFi-BT) -- [PSoC 6 BLE Pioneer Kit](https://www.cypress.com/CY8CKIT-062-BLE) (CY8CKIT-062-BLE) -- [PSoC 6 BLE Prototyping Kit](https://www.cypress.com/CY8CPROTO-063-BLE) (CY8CPROTO-063-BLE) -- [PSoC 62S2 Wi-Fi BT Pioneer Kit](https://www.cypress.com/CY8CKIT-062S2-43012) (CY8CKIT-062S2-43012) -- [PSoC 62S1 Wi-Fi BT Pioneer Kit](https://www.cypress.com/CYW9P62S1-43438EVB-01) (CYW9P62S1-43438EVB-01) -- [PSoC 62S1 Wi-Fi BT Pioneer Kit](https://www.cypress.com/CYW9P62S1-43012EVB-01) (CYW9P62S1-43012EVB-01) -- [PSoC 62S3 Wi-Fi BT Prototyping Kit](https://www.cypress.com/CY8CPROTO-062S3-4343W) (CY8CPROTO-062S3-4343W) - -## Hardware Setup - -This example uses the board's default configuration. See the kit user guide to ensure that the board is configured correctly. - -**Note**: The PSoC 6 BLE Pioneer Kit and the PSoC 6 WiFi-BT Pioneer Kit ship with KitProg2 installed. ModusToolbox software requires KitProg3. Before using this code example, make sure that the board is upgraded to KitProg3. The tool and instructions are available in the [Firmware Loader](https://github.com/cypresssemiconductorco/Firmware-loader) GitHub repository. If you do not upgrade, you will see an error like "unable to find CMSIS-DAP device" or "KitProg firmware is out of date". - -## Software Setup -See the [Operation](#operation) section for information on how to modify the code for each demo. - -## Using the Code Example - -### In Eclipse IDE for ModusToolbox: - -1. Click the **New Application** link in the Quick Panel (or, use **File** > **New** > **ModusToolbox Application**). - -2. Pick a kit supported by the code example from the list shown in the **Project Creator - Choose Board Support Package (BSP)** dialog. - - When you select a supported kit, the example is reconfigured automatically to work with the kit. To work with a different supported kit later, use the **Library Manager** to choose the BSP for the supported kit. You can use the **Library Manager** to select or update the BSP and firmware libraries used in this application. To access the **Library Manager**, right-click the application name from the Project Workspace window in the IDE, and select **ModusToolbox** > **Library Manager**. - - You can also just start the application creation process again and select a different kit. - - If you want to use the application for a kit not listed here, you may need to update source files. If the kit does not have the required resources, the application may not work. - -3. In the **Project Creator - Choose Board Support Package (BSP)** dialog, choose the example. - -4. Optionally, update the **Application Name:** and **Location** fields with the application name and local path where application is created. - -5. Click **Create** and complete the application creation process. - -For more details, see the Eclipse IDE for ModusToolbox User Guide: *{ModusToolbox install directory}/ide_{version}/docs/mt_ide_user_guide.pdf*. - -### In Command-line Interface (CLI): - -1. Download and unzip this repository onto your local machine, or clone the repository. - -2. Open a CLI terminal and navigate to the application folder. On Linux and macOS, you can use any terminal application. On Windows, navigate to the *modus-shell* directory (*{ModusToolbox install directory}/tools_\/modus-shell*) and run Cygwin.bat. - -3. Import required libraries by executing the `make getlibs` command. - -### In Third-party IDEs: - -1. Follow instructions from the CLI section to download or clone the repository, and import libraries using `make getlibs` command. - -2. Export the application to a supported IDE using the `make ` command. - -3. Follow instructions displayed in the terminal to create or import the application as an IDE project. - -For more details, see *Exporting to IDEs* section of the ModusToolbox User Guide: *{ModusToolbox install directory}/ide_{version}/docs/mtb_user_guide.pdf*. - -## Operation - -1. Connect the board to your PC using the provided USB cable through the USB connector. - -2. Modify the makefile if you want to use RESET mode. By default, the example is in INTERRUPT mode. - 1. Open the makefile from *mtb-example-psoc6-wdt* in the workspace. - - 2. Set `WDT_DEMO to WDT_RESET_DEMO` for reset demonstration as shown below: - - ``` - DEFINES=WDT_DEMO=WDT_RESET_DEMO - ``` - 3. To demonstrate WDT reset, a blocking code `(while(1))` is introduced in the innermost `for` loop by enabling the define `DEFINES+=EXECUTION_BLOCK` in the makefile. - -3. When `WDT_INTERRUPT_DEMO` is selected, you can optionally put the device in Deep Sleep mode by enabling the define `DEFINES+=DEEPSLEEP_ENABLE` in the makefile. The device wakes up from Deep Sleep mode on a WDT -interrupt. - -4. Program the board. - - ### Using Eclipse IDE for ModusToolbox: - - 1. Select the application project in the Project Explorer. - - 2. In the **Quick Panel**, scroll down, and click **\ Program (KitProg3)**. - - ### Using CLI: - - 1. From the terminal, execute the `make program` command to build and program the application using the default toolchain to the default target. You can specify a target and toolchain manually: - ``` - make program TARGET= TOOLCHAIN= - ``` - Example: - - ``` - make program TARGET=CY8CKIT-062-WIFI-BT TOOLCHAIN=GCC_ARM - ``` - **Note**: Before building the application, ensure that the *deps* folder contains the BSP file (*TARGET_xxx.lib*) corresponding to the TARGET. Execute the `make getlibs` command to fetch the BSP contents before building the application. - -5. Observe the status of the LEDs based on different events summarized as follows: - -| Project Setting | LED Status | -| :----------------------------------------------------------- | :----------------------------------------------------------- | -| `WDT_DEMO` set to `WDT_INTERRUPT_DEMO` | User LED toggles on every WDT interrupt (interval of 1 s). | -| `WDT_DEMO` set to `WDT_RESET_DEMO` with the blocking function | After approximately 4 s, the device resets and the user LED blinks twice within a second to indicate a WDT reset. | -| `WDT_DEMO` set to `WDT_RESET_DEMO` without the blocking function| User LED toggles every 1 s to indicate that the CPU is in action. | - -Note that user LED blinks once on a power cycle or an external reset event. - -## Design and Implementation - -### Resources and Settings - -[Table 1](#table-1-application-resources) lists the ModusToolbox resources used in this example, and how they are used in the design. - -##### Table 1. Application Resources -| Resource | Alias/Object | Purpose | -| :------- | :------------ | :------------ | -| WDT (PDL and HAL) | - | WDT driver to configure the hardware resource | -| GPIO (HAL) | CYBSP_USER_LED | User LED | - -The WDT in PSoC 6 MCU is a 16-bit timer and uses the Internal Low-Speed Oscillator (ILO) clock of 32 kHz. WDT is configured using different set of APIs, depending on whether interrupt mode is selected or the reset mode. -Follow these steps, in the project, to configure WDT when `WDT_INTERRUPT_DEMO` is selected: - -1. Unlock the WDT to enable configuration. - -2. Set the 'ignore' bits for the match resolution. In the project, it is set to ‘0’; that means full 16-bit resolution for the match count, which gives an interval of 2.048 s (65536 ÷ 32kHz) for the match event. - -3. Write the match value. The WDT can generate an interrupt (if enabled) when the WDT counter reaches the match count. The project configures the match count using the `WDT_MATCH_COUNT` macro. Note that the interrupt handler -modifies the match count to generate a periodic interrupt. - -4. Clear the pending WDT interrupt. - -5. Enable the ILO, which is the source for the WDT. - -6. Enable interrupt generation and assign the handler. - -7. Enable WDT. - -8. Lock the WDT to prevent inadvertent changes. - -For using `WDT_RESET_DEMO`, there are set of easy to use APIs to initialize the WDT hardware for a desired time out period. APIs configure the ignore bits and the match count for the desired time out period. Time out period comprises of three match events. To avoid WDT reset, firmware needs to clear the WDT before the third match event. - -**Notes:** - -1. The WDT generates an interrupt on match. However, the counter is not reset on match. It continues to count across the full 16-bit resolution. For this reason, the match count is updated on every WDT interrupt when -`WDT_INTERRUPT_DEMO` is selected. - -2. Interrupt should not be enabled when `WDT_RESET_DEMO` is being used. If interrupt is enabled, upon an interrupt, it needs to be cleared to avoid repeated execution of the WDT interrupt handler. This removes the actual purpose of the WDT. Thus, interrupt generation should never be enabled and the WDT match event should always be cleared in the main loop. - -| Macro | Value | Purpose | -| :----------------------| :--------------| :-------------------------------------------------------------------------------- | -| `WDT_DEMO` | `WDT_RESET_DEMO` | In this mode of the WDT, interrupt generation is not enabled and the WDT match event is cleared in the main loop.| -| `WDT_DEMO` | `WDT_INTERRUPT_DEMO` (default) | In this mode of the WDT, interrupt generation is enabled and the match event is cleared in the interrupt handler. The match count is updated to get the next interrupt after the same interval. | -| `WDT_INTERRUPT_INTERVAL_MS` | `1000` (default) | Specifies the interrupt interval in milliseconds. In this case, it is set to 1000 millisecond. Change this value to get a different interrupt interval. The maximum interval can be 2047 millisecond | -| `WDT_TIME_OUT_MS` | `4000` (default) | Specifies the time out for reset event in milliseconds. Change this value to get a different time out. The maximum time out that can be set is given by `CYHAL_WDT_MAX_TIMEOUT_MS`.| - -To simulate a malfunction, the main loop contains a blocking function (infinite `while` loop). Enabling this blocking function causes WDT match events not to be cleared. After three match events, the device resets. The firmware blinks the user LED twice when the device comes out of reset. - -## Related Resources - -| **Application Notes** | | -| :----------------------------------------------------------- | :----------------------------------------------------------- | -| [AN228571](https://www.cypress.com/AN228571) – Getting Started with PSoC 6 MCU on ModusToolbox | Describes PSoC 6 MCU devices and how to build your first application with ModusToolbox | -| [AN221774](https://www.cypress.com/AN221774) – Getting Started with PSoC 6 MCU on PSoC Creator | Describes PSoC 6 MCU devices and how to build your first application with PSoC Creator | -| [AN210781](https://www.cypress.com/AN210781) – Getting Started with PSoC 6 MCU with Bluetooth Low Energy (BLE) Connectivity on PSoC Creator | Describes PSoC 6 MCU with BLE Connectivity devices and how to build your first application with PSoC Creator | -| [AN215656](https://www.cypress.com/AN215656) – PSoC 6 MCU: Dual-CPU System Design | Describes the dual-CPU architecture in PSoC 6 MCU, and shows how to build a simple dual-CPU design | -| [AN219528](https://www.cypress.com/AN219528) – PSoC 6 MCU: Low-Power Modes and Power Reduction Techniques | Describes how to use the PSoC 6 MCU power modes to optimize power consumption | -| **Code Examples** | | -| [Using ModusToolbox](https://github.com/cypresssemiconductorco/Code-Examples-for-ModusToolbox-Software) | [Using PSoC Creator](https://www.cypress.com/documentation/code-examples/psoc-6-mcu-code-examples) | -| **Device Documentation** | | -| [PSoC 6 MCU Datasheets](https://www.cypress.com/search/all?f[0]=meta_type%3Atechnical_documents&f[1]=resource_meta_type%3A575&f[2]=field_related_products%3A114026) | [PSoC 6 Technical Reference Manuals](https://www.cypress.com/search/all/PSoC%206%20Technical%20Reference%20Manual?f[0]=meta_type%3Atechnical_documents&f[1]=resource_meta_type%3A583) | -| **Development Kits** | Buy at www.cypress.com | -| [CY8CKIT-062-BLE](https://www.cypress.com/CY8CKIT-062-BLE) PSoC 6 BLE Pioneer Kit | [CY8CKIT-062-WiFi-BT](https://www.cypress.com/CY8CKIT-062-WiFi-BT) PSoC 6 WiFi-BT Pioneer Kit | -| [CY8CPROTO-063-BLE](https://www.cypress.com/CY8CPROTO-063-BLE) PSoC 6 BLE Prototyping Kit | [CY8CPROTO-062-4343W](https://www.cypress.com/CY8CPROTO-062-4343W) PSoC 6 Wi-Fi BT Prototyping Kit | -| [CY8CKIT-062S2-43012](https://www.cypress.com/CY8CKIT-062S2-43012) PSoC 62S2 Wi-Fi BT Pioneer Kit | [CY8CPROTO-062S3-4343W](https://www.cypress.com/CY8CPROTO-062S3-4343W) PSoC 62S3 Wi-Fi BT Prototyping Kit | -| [CYW9P62S1-43438EVB-01](https://www.cypress.com/CYW9P62S1-43438EVB-01) PSoC 62S1 Wi-Fi BT Pioneer Kit | [CYW9P62S1-43012EVB-01](https://www.cypress.com/CYW9P62S1-43012EVB-01) PSoC 62S1 Wi-Fi BT Pioneer Kit | | -| **Libraries** | | -| PSoC 6 Peripheral Driver Library (PDL) and docs | [psoc6pdl](https://github.com/cypresssemiconductorco/psoc6pdl) on GitHub | -| Cypress Hardware Abstraction Layer (HAL) Library and docs | [psoc6hal](https://github.com/cypresssemiconductorco/psoc6hal) on GitHub | -| RetargetIO - A utility library to retarget the standard input/output (STDIO) messages to a UART port | [retarget-io](https://github.com/cypresssemiconductorco/retarget-io) on GitHub | -| **Middleware** | | -| CapSense library and docs | [capsense](https://github.com/cypresssemiconductorco/capsense) on GitHub | -| Links to all PSoC 6 MCU Middleware | [psoc6-middleware](https://github.com/cypresssemiconductorco/psoc6-middleware) on GitHub | -| **Tools** | | -| [Eclipse IDE for ModusToolbox](https://www.cypress.com/modustoolbox) | The multi-platform, Eclipse-based Integrated Development Environment (IDE) that supports application configuration and development for PSoC 6 MCU and IoT designers. | -| [PSoC Creator](https://www.cypress.com/products/psoc-creator-integrated-design-environment-ide) | The Cypress IDE for PSoC and FM0+ MCU development. | - -## Other Resources - -Cypress provides a wealth of data at www.cypress.com to help you select the right device, and quickly and effectively integrate it into your design. - -For PSoC 6 MCU devices, see [How to Design with PSoC 6 MCU - KBA223067](https://community.cypress.com/docs/DOC-14644) in the Cypress community. - -## Document History - -Document Title: CE220060 - PSoC 6 MCU Watchdog Timer - -| Version | Description of Change | -| ------- | --------------------- | -| 1.0.0 | New code example | -| 1.1.0 | Updated to support ModusToolbox software v2.1, added new kits
Minor changes to code | - ------- - -All other trademarks or registered trademarks referenced herein are the property of their respective owners. - -![Banner](images/Banner.png) - -------------------------------------------------------------------------------- - -© Cypress Semiconductor Corporation, 2019-2020. This document is the property of Cypress Semiconductor Corporation and its subsidiaries ("Cypress"). This document, including any software or firmware included or referenced in this document ("Software"), is owned by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of Cypress's patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited. -TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. No computing device can be absolutely secure. Therefore, despite security measures implemented in Cypress hardware or software products, Cypress shall have no liability arising out of any security breach, such as unauthorized access to or use of a Cypress product. CYPRESS DOES NOT REPRESENT, WARRANT, OR GUARANTEE THAT CYPRESS PRODUCTS, OR SYSTEMS CREATED USING CYPRESS PRODUCTS, WILL BE FREE FROM CORRUPTION, ATTACK, VIRUSES, INTERFERENCE, HACKING, DATA LOSS OR THEFT, OR OTHER SECURITY INTRUSION (collectively, "Security Breach"). Cypress disclaims any liability relating to any Security Breach, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from any Security Breach. In addition, the products described in these materials may contain design defects or errors known as errata which may cause the product to deviate from published specifications. To the extent permitted by applicable law, Cypress reserves the right to make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or circuit described in this document. Any information provided in this document, including any sample design information or programming code, is provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and safety of any application made of this information and any resulting product. "High-Risk Device" means any device or system whose failure could cause personal injury, death, or property damage. Examples of High-Risk Devices are weapons, nuclear installations, surgical implants, and other medical devices. "Critical Component" means any component of a High-Risk Device whose failure to perform can be reasonably expected to cause, directly or indirectly, the failure of the High-Risk Device, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from any use of a Cypress product as a Critical Component in a High-Risk Device. You shall indemnify and hold Cypress, its directors, officers, employees, agents, affiliates, distributors, and assigns harmless from and against all claims, costs, damages, and expenses, arising out of any claim, including claims for product liability, personal injury or death, or property damage arising from any use of a Cypress product as a Critical Component in a High-Risk Device. Cypress products are not intended or authorized for use as a Critical Component in any High-Risk Device except to the limited extent that (i) Cypress's published data sheet for the product explicitly states Cypress has qualified the product for use in a specific High-Risk Device, or (ii) Cypress has given you advance written authorization to use the product as a Critical Component in the specific High-Risk Device and you have signed a separate indemnification agreement. -Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, WICED, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other names and brands may be claimed as property of their respective owners. +# PSoC 6 MCU Watchdog Timer + + +This example explains how to set up a Watchdog Timer (WDT) using the [WDT](https://cypresssemiconductorco.github.io/mtb-hal-cat1/html/group__group__hal__wdt.html) HAL resource. The WDT resets the device if it is not serviced or "kicked" within the configured timeout interval. This helps in recovering the program from an unintended lock up. + +By default, the WDT is reset at least once within each timeout interval to avoid a device reset. The user LED toggles every 1 s in the main loop to indicate that the CPU is in action. In addition, the user LED blinks once for power cycling or an external reset event. + +Enable an infinite loop in the `main()` function to block the execution. The device resets in ~4 s. The user LED blinks twice after the device comes out of reset. + +[Provide feedback on this Code Example.](https://cypress.co1.qualtrics.com/jfe/form/SV_1NTns53sK2yiljn?Q_EED=eyJVbmlxdWUgRG9jIElkIjoiQ0UyMjAwNjAiLCJTcGVjIE51bWJlciI6IjAwMi0yMDA2MCIsIkRvYyBUaXRsZSI6IlBTb0MgNiBNQ1UgV2F0Y2hkb2cgVGltZXIiLCJyaWQiOiJzZGFrIiwiRG9jIHZlcnNpb24iOiIyLjAuMCIsIkRvYyBMYW5ndWFnZSI6IkVuZ2xpc2giLCJEb2MgRGl2aXNpb24iOiJNQ0QiLCJEb2MgQlUiOiJJQ1ciLCJEb2MgRmFtaWx5IjoiUFNPQyJ9) + +## Requirements + +- [ModusToolbox® software](https://www.cypress.com/products/modustoolbox-software-environment) v2.2 + + + **Note:** This code example version requires ModusToolbox software version 2.2 or later and is not backward compatible with v2.1 or older versions. If you cannot move to ModusToolbox v2.2, use the latest compatible version of this example: [latest-v1.X](https://github.com/cypresssemiconductorco/mtb-example-psoc6-wdt/tree/latest-v1.X). + +- Board Support Package (BSP) minimum required version: 2.0.0 +- Programming Language: C +- Associated Parts: All [PSoC® 6 MCU](http://www.cypress.com/PSoC6) parts + +## Supported Toolchains (make variable 'TOOLCHAIN') + +- GNU Arm® Embedded Compiler v9.3.1 (`GCC_ARM`) - Default value of `TOOLCHAIN` +- Arm compiler v6.13 (`ARM`) +- IAR C/C++ compiler v8.42.2 (`IAR`) + + +## Supported Kits (make variable 'TARGET') + +- [PSoC 6 Wi-Fi BT Prototyping Kit](https://www.cypress.com/CY8CPROTO-062-4343W) (`CY8CPROTO-062-4343W`) - Default value of `TARGET` +- [PSoC 6 WiFi-BT Pioneer Kit](https://www.cypress.com/CY8CKIT-062-WiFi-BT) (`CY8CKIT-062-WIFI-BT`) +- [PSoC 6 BLE Pioneer Kit](https://www.cypress.com/CY8CKIT-062-BLE) (`CY8CKIT-062-BLE`) +- [PSoC 6 BLE Prototyping Kit](https://www.cypress.com/CY8CPROTO-063-BLE) (`CY8CPROTO-063-BLE`) +- [PSoC 62S2 Wi-Fi BT Pioneer Kit](https://www.cypress.com/CY8CKIT-062S2-43012) (`CY8CKIT-062S2-43012`) +- [PSoC 62S1 Wi-Fi BT Pioneer Kit](https://www.cypress.com/CYW9P62S1-43438EVB-01) (`CYW9P62S1-43438EVB-01`) +- [PSoC 62S1 Wi-Fi BT Pioneer Kit](https://www.cypress.com/CYW9P62S1-43012EVB-01) (`CYW9P62S1-43012EVB-01`) +- [PSoC 62S3 Wi-Fi BT Prototyping Kit](https://www.cypress.com/CY8CPROTO-062S3-4343W) (`CY8CPROTO-062S3-4343W`) +- [PSoC 64 Secure Boot Wi-Fi BT Pioneer Kit](http://www.cypress.com/CY8CKIT-064B0S2-4343W) (`CY8CKIT-064B0S2-4343W`) + +## Hardware Setup + +This example uses the board's default configuration. See the kit user guide to ensure that the board is configured correctly. + +**Note:** The PSoC 6 BLE Pioneer Kit (CY8CKIT-062-BLE) and the PSoC 6 WiFi-BT Pioneer Kit (CY8CKIT-062-WIFI-BT) ship with KitProg2 installed. The ModusToolbox software requires KitProg3. Before using this code example, make sure that the board is upgraded to KitProg3. The tool and instructions are available in the [Firmware Loader](https://github.com/cypresssemiconductorco/Firmware-loader) GitHub repository. If you do not upgrade, you will see an error like "unable to find CMSIS-DAP device" or "KitProg firmware is out of date". + +## Software Setup +See the [Operation](#operation) section for information on how to modify the code for each event. + +## Using the Code Example + +Create the project and open it using one of the following: + +
In Eclipse IDE for ModusToolbox + +1. Click the **New Application** link in the **Quick Panel** (or, use **File** > **New** > **ModusToolbox Application**). This launches the [Project Creator](http://www.cypress.com/ModusToolboxProjectCreator) tool. + +2. Pick a kit supported by the code example from the list shown in the **Project Creator - Choose Board Support Package (BSP)** dialog. + + When you select a supported kit, the example is reconfigured automatically to work with the kit. To work with a different supported kit later, use the [Library Manager](https://www.cypress.com/ModusToolboxLibraryManager) to choose the BSP for the supported kit. You can use the Library Manager to select or update the BSP and firmware libraries used in this application. To access the Library Manager, click the link from the **Quick Panel**. + + You can also just start the application creation process again and select a different kit. + + If you want to use the application for a kit not listed here, you may need to update the source files. If the kit does not have the required resources, the application may not work. + +3. In the **Project Creator - Select Application** dialog, choose the example by enabling the checkbox. + +4. Optionally, change the suggested **New Application Name**. + +5. Enter the local path in the **Application(s) Root Path** field to indicate where the application needs to be created. + + Applications that can share libraries can be placed in the same root path. + +6. Click **Create** to complete the application creation process. + +For more details, see the [Eclipse IDE for ModusToolbox User Guide](https://www.cypress.com/MTBEclipseIDEUserGuide) (locally available at *{ModusToolbox install directory}/ide_{version}/docs/mt_ide_user_guide.pdf*). + +
+ +
In Command-line Interface (CLI) + +ModusToolbox provides the Project Creator as both a GUI tool and a command line tool to easily create one or more ModusToolbox applications. See the "Project Creator Tools" section of the [ModusToolbox User Guide](https://www.cypress.com/ModusToolboxUserGuide) for more details. + +Alternatively, you can manually create the application using the following steps: + +1. Download and unzip this repository onto your local machine, or clone the repository. + +2. Open a CLI terminal and navigate to the application folder. + + On Linux and macOS, you can use any terminal application. On Windows, open the **modus-shell** app from the Start menu. + + **Note:** The cloned application contains a default BSP file (*TARGET_xxx.mtb*) in the *deps* folder. Use the [Library Manager](https://www.cypress.com/ModusToolboxLibraryManager) (`make modlibs` command) to select and download a different BSP file, if required. If the selected kit does not have the required resources or is not [supported](#supported-kits-make-variable-target), the application may not work. + +3. Import the required libraries by executing the `make getlibs` command. + +Various CLI tools include a `-h` option that prints help information to the terminal screen about that tool. For more details, see the [ModusToolbox User Guide](https://www.cypress.com/ModusToolboxUserGuide) (locally available at *{ModusToolbox install directory}/docs_{version}/mtb_user_guide.pdf*). + +
+ +
In Third-party IDEs + +1. Follow the instructions from the **In Command-line Interface (CLI)** section to create the application, and import the libraries using the `make getlibs` command. + +2. Export the application to a supported IDE using the `make ` command. + + For a list of supported IDEs and more details, see the "Exporting to IDEs" section of the [ModusToolbox User Guide](https://www.cypress.com/ModusToolboxUserGuide) (locally available at *{ModusToolbox install directory}/docs_{version}/mtb_user_guide.pdf*. + +3. Follow the instructions displayed in the terminal to create or import the application as an IDE project. + +
+ +## Operation + +1. Connect the board to your PC using the provided USB cable through the KitProg3 USB connector. + +2. Enable the blocking function ( to demonstrate WDT reset ) by updating the macro `ENABLE_BLOCKING_FUNCTION` in the main.c as shown below: + ``` + #define ENABLE_BLOCKING_FUNCTION 1 + ``` + +3. Program the board using one of the following: + +
Using Eclipse IDE for ModusToolbox + + 1. Select the application project in the Project Explorer. + + 2. In the **Quick Panel**, scroll down, and click **\ Program (KitProg3_MiniProg4)**. +
+ +
Using CLI + + From the terminal, execute the `make program` command to build and program the application using the default toolchain to the default target. You can specify a target and toolchain manually: + ``` + make program TARGET= TOOLCHAIN= + ``` + + Example: + ``` + make program TARGET=CY8CPROTO-062-4343W TOOLCHAIN=GCC_ARM + ``` +
+ +4. Observe the status of the LEDs based on different events summarized as follows: + +| Project Setting | LED Status | +| :----------------------------------------------------------- | :----------------------------------------------------------- | +| With the blocking function | After approximately 4 s, the device resets and the user LED blinks twice within a second to indicate a WDT reset. | +| Without the blocking function| User LED toggles every 1 s to indicate that the CPU is in action. | + +Note that the user LED blinks once on a power cycle or an external reset event. + +## Design and Implementation + +### Resources and Settings + +**Table 1. Application Resources** + +| Resource | Alias/Object | Purpose | +| :------- | :------------ | :------------ | +| WDT (HAL) | wdt_obj | WDT driver to configure the hardware resource | +| GPIO (HAL) | CYBSP_USER_LED | User LED | + +The WDT in PSoC 6 MCU is a 16-bit timer and uses the Internal Low-Speed Oscillator (ILO) clock of 32 kHz. The WDT is configured using HAL APIs. These APIs configure the ignore bits and the match count for the desired period. The total timeout period of the WDT consists of three match events. To avoid a WDT reset, firmware must clear the WDT before the third match event. + +**Notes:** + +The interrupt should never be enabled and the WDT match event should always be cleared in the main loop. If interrupt is enabled, upon an interrupt, it needs to be cleared to avoid repeated execution of the WDT interrupt handler. This removes the actual purpose of the WDT. + +The `WDT_TIME_OUT_MS` macro specifies the timeout for the reset event in milliseconds. The default value is `4000`. Change this value to get a different time out. The maximum timeout that can be set is given by `CYHAL_WDT_MAX_TIMEOUT_MS`. + +To simulate a malfunction, the main loop contains a blocking function (infinite `while` loop). Enabling this blocking function causes WDT match events not to be cleared. After three match events, the device resets. The firmware blinks the user LED twice when the device comes out of reset. + +## Related Resources + +| Application Notes | | +| :----------------------------------------------------------- | :----------------------------------------------------------- | +| [AN228571](https://www.cypress.com/AN228571) – Getting Started with PSoC 6 MCU on ModusToolbox | Describes PSoC 6 MCU devices and how to build your first application with ModusToolbox | +| [AN221774](https://www.cypress.com/AN221774) – Getting Started with PSoC 6 MCU on PSoC Creator | Describes PSoC 6 MCU devices and how to build your first application with PSoC Creator | +| [AN210781](https://www.cypress.com/AN210781) – Getting Started with PSoC 6 MCU with Bluetooth Low Energy (BLE) Connectivity on PSoC Creator | Describes PSoC 6 MCU with BLE Connectivity devices and how to build your first application with PSoC Creator | +| [AN215656](https://www.cypress.com/AN215656) – PSoC 6 MCU: Dual-CPU System Design | Describes the dual-CPU architecture in PSoC 6 MCU, and shows how to build a simple dual-CPU design | +| **Code Examples** | | +| [Using ModusToolbox](https://github.com/cypresssemiconductorco/Code-Examples-for-ModusToolbox-Software) | [Using PSoC Creator](https://www.cypress.com/documentation/code-examples/psoc-6-mcu-code-examples) | +| **Device Documentation** | | +| [PSoC 6 MCU Datasheets](https://www.cypress.com/search/all?f[0]=meta_type%3Atechnical_documents&f[1]=resource_meta_type%3A575&f[2]=field_related_products%3A114026) | [PSoC 6 Technical Reference Manuals](https://www.cypress.com/search/all/PSoC%206%20Technical%20Reference%20Manual?f[0]=meta_type%3Atechnical_documents&f[1]=resource_meta_type%3A583) | +| **Development Kits** | Buy at www.cypress.com | +| [CY8CKIT-062-BLE](https://www.cypress.com/CY8CKIT-062-BLE) PSoC 6 BLE Pioneer Kit | [CY8CKIT-062-WiFi-BT](https://www.cypress.com/CY8CKIT-062-WiFi-BT) PSoC 6 WiFi-BT Pioneer Kit | +| [CY8CPROTO-063-BLE](https://www.cypress.com/CY8CPROTO-063-BLE) PSoC 6 BLE Prototyping Kit | [CY8CPROTO-062-4343W](https://www.cypress.com/CY8CPROTO-062-4343W) PSoC 6 Wi-Fi BT Prototyping Kit | +| [CY8CKIT-062S2-43012](https://www.cypress.com/CY8CKIT-062S2-43012) PSoC 62S2 Wi-Fi BT Pioneer Kit | [CY8CPROTO-062S3-4343W](https://www.cypress.com/CY8CPROTO-062S3-4343W) PSoC 62S3 Wi-Fi BT Prototyping Kit | +| [CYW9P62S1-43438EVB-01](https://www.cypress.com/CYW9P62S1-43438EVB-01) PSoC 62S1 Wi-Fi BT Pioneer Kit | [CYW9P62S1-43012EVB-01](https://www.cypress.com/CYW9P62S1-43012EVB-01) PSoC 62S1 Wi-Fi BT Pioneer Kit | +| [CY8CKIT-064B0S2-4343W](http://www.cypress.com/CY8CKIT-064B0S2-4343W) PSoC 64 Secure Boot Wi-Fi BT Pioneer Kit | | +| **Libraries** | | +| PSoC 6 Peripheral Driver Library (PDL) and docs | [mtb-pdl-cat1](https://github.com/cypresssemiconductorco/mtb-pdl-cat1) on GitHub | +| Cypress Hardware Abstraction Layer (HAL) Library and docs | [mtb-hal-cat1](https://github.com/cypresssemiconductorco/mtb-hal-cat1) on GitHub | +| Retarget IO - A utility library to retarget the standard input/output (STDIO) messages to a UART port | [retarget-io](https://github.com/cypresssemiconductorco/retarget-io) on GitHub | +| **Middleware** | | +| CapSense® library and docs | [capsense](https://github.com/cypresssemiconductorco/capsense) on GitHub | +| Links to all PSoC 6 MCU Middleware | [psoc6-middleware](https://github.com/cypresssemiconductorco/psoc6-middleware) on GitHub | +| **Tools** | | +| [Eclipse IDE for ModusToolbox](https://www.cypress.com/modustoolbox) | The cross-platform, Eclipse-based IDE for IoT designers that supports application configuration and development targeting converged MCU and wireless systems. | +| [PSoC Creator™](https://www.cypress.com/products/psoc-creator-integrated-design-environment-ide) | The Cypress IDE for PSoC and FM0+ MCU development. | + +## Other Resources + +Cypress provides a wealth of data at www.cypress.com to help you select the right device, and quickly and effectively integrate it into your design. + +For PSoC 6 MCU devices, see [How to Design with PSoC 6 MCU - KBA223067](https://community.cypress.com/docs/DOC-14644) in the Cypress community. + +## Document History + +Document Title: *CE220060* - *PSoC 6 MCU Watchdog Timer* + +| Version | Description of Change | +| ------- | --------------------- | +| 1.0.0 | New code example. | +| 1.1.0 | Updated to support ModusToolbox software v2.1, added new kits.
Minor changes to code. | +| 2.0.0 | Major update to support ModusToolbox software v2.2, added support for new kits.
This version is not backward compatible with ModusToolbox software v2.1.
Updated the code example to demonstrate watchdog reset using HAL alone. | +------ + +All other trademarks or registered trademarks referenced herein are the property of their respective owners. + +![banner](images/ifx-cy-banner.png) + +------------------------------------------------------------------------------- + +© Cypress Semiconductor Corporation (An Infineon Technologies Company), 2020. This document is the property of Cypress Semiconductor Corporation and its affiliates ("Cypress"). This document, including any software or firmware included or referenced in this document ("Software"), is owned by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of Cypress's patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited.
+TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. No computing device can be absolutely secure. Therefore, despite security measures implemented in Cypress hardware or software products, Cypress shall have no liability arising out of any security breach, such as unauthorized access to or use of a Cypress product. CYPRESS DOES NOT REPRESENT, WARRANT, OR GUARANTEE THAT CYPRESS PRODUCTS, OR SYSTEMS CREATED USING CYPRESS PRODUCTS, WILL BE FREE FROM CORRUPTION, ATTACK, VIRUSES, INTERFERENCE, HACKING, DATA LOSS OR THEFT, OR OTHER SECURITY INTRUSION (collectively, "Security Breach"). Cypress disclaims any liability relating to any Security Breach, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from any Security Breach. In addition, the products described in these materials may contain design defects or errors known as errata which may cause the product to deviate from published specifications. To the extent permitted by applicable law, Cypress reserves the right to make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or circuit described in this document. Any information provided in this document, including any sample design information or programming code, is provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and safety of any application made of this information and any resulting product. "High-Risk Device" means any device or system whose failure could cause personal injury, death, or property damage. Examples of High-Risk Devices are weapons, nuclear installations, surgical implants, and other medical devices. "Critical Component" means any component of a High-Risk Device whose failure to perform can be reasonably expected to cause, directly or indirectly, the failure of the High-Risk Device, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from any use of a Cypress product as a Critical Component in a High-Risk Device. You shall indemnify and hold Cypress, its directors, officers, employees, agents, affiliates, distributors, and assigns harmless from and against all claims, costs, damages, and expenses, arising out of any claim, including claims for product liability, personal injury or death, or property damage arising from any use of a Cypress product as a Critical Component in a High-Risk Device. Cypress products are not intended or authorized for use as a Critical Component in any High-Risk Device except to the limited extent that (i) Cypress's published data sheet for the product explicitly states Cypress has qualified the product for use in a specific High-Risk Device, or (ii) Cypress has given you advance written authorization to use the product as a Critical Component in the specific High-Risk Device and you have signed a separate indemnification agreement.
+Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, WICED, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other names and brands may be claimed as property of their respective owners. diff --git a/deps/TARGET_CY8CKIT-062-WIFI-BT.lib b/deps/TARGET_CY8CKIT-062-WIFI-BT.lib deleted file mode 100644 index 7d1d41b..0000000 --- a/deps/TARGET_CY8CKIT-062-WIFI-BT.lib +++ /dev/null @@ -1 +0,0 @@ -https://github.com/cypresssemiconductorco/TARGET_CY8CKIT-062-WIFI-BT/#latest-v1.X diff --git a/deps/TARGET_CY8CPROTO-062-4343W.lib b/deps/TARGET_CY8CPROTO-062-4343W.lib deleted file mode 100644 index 72d7312..0000000 --- a/deps/TARGET_CY8CPROTO-062-4343W.lib +++ /dev/null @@ -1 +0,0 @@ -https://github.com/cypresssemiconductorco/TARGET_CY8CPROTO-062-4343W/#latest-v1.X diff --git a/deps/TARGET_CY8CPROTO-062-4343W.mtb b/deps/TARGET_CY8CPROTO-062-4343W.mtb new file mode 100644 index 0000000..4e94fc0 --- /dev/null +++ b/deps/TARGET_CY8CPROTO-062-4343W.mtb @@ -0,0 +1 @@ +https://github.com/cypresssemiconductorco/TARGET_CY8CPROTO-062-4343W#latest-v2.X#$$ASSET_REPO$$/TARGET_CY8CPROTO-062-4343W/latest-v2.X diff --git a/images/Banner.png b/images/Banner.png deleted file mode 100644 index 8e83973..0000000 Binary files a/images/Banner.png and /dev/null differ diff --git a/images/SampleImage.png b/images/SampleImage.png deleted file mode 100644 index e104b2d..0000000 Binary files a/images/SampleImage.png and /dev/null differ diff --git a/images/ifx-cy-banner.png b/images/ifx-cy-banner.png new file mode 100644 index 0000000..3f9872b Binary files /dev/null and b/images/ifx-cy-banner.png differ diff --git a/main.c b/main.c index 3ed5ca3..8b57e16 100644 --- a/main.c +++ b/main.c @@ -2,27 +2,29 @@ * File Name: main.c * * Description: This is the source code for the PSoC 6 MCU Watchdog Timer Example. +* for ModusToolbox. * * Related Document: See README.md * * ******************************************************************************* -* Copyright 2019-2020, Cypress Semiconductor Corporation. All rights reserved. -******************************************************************************* -* This software, including source code, documentation and related materials -* ("Software"), is owned by Cypress Semiconductor Corporation or one of its -* subsidiaries ("Cypress") and is protected by and subject to worldwide patent -* protection (United States and foreign), United States copyright laws and -* international treaty provisions. Therefore, you may use this Software only -* as provided in the license agreement accompanying the software package from -* which you obtained this Software ("EULA"). +* Copyright 2019-2021, Cypress Semiconductor Corporation (an Infineon company) or +* an affiliate of Cypress Semiconductor Corporation. All rights reserved. * +* This software, including source code, documentation and related +* materials ("Software") is owned by Cypress Semiconductor Corporation +* or one of its affiliates ("Cypress") and is protected by and subject to +* worldwide patent protection (United States and foreign), +* United States copyright laws and international treaty provisions. +* Therefore, you may use this Software only as provided in the license +* agreement accompanying the software package from which you +* obtained this Software ("EULA"). * If no EULA applies, Cypress hereby grants you a personal, non-exclusive, -* non-transferable license to copy, modify, and compile the Software source -* code solely for use in connection with Cypress's integrated circuit products. -* Any reproduction, modification, translation, compilation, or representation -* of this Software except as specified above is prohibited without the express -* written permission of Cypress. +* non-transferable license to copy, modify, and compile the Software +* source code solely for use in connection with Cypress's +* integrated circuit products. Any reproduction, modification, translation, +* compilation, or representation of this Software except as specified +* above is prohibited without the express written permission of Cypress. * * Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED @@ -33,62 +35,41 @@ * not authorize its products for use in any products where a malfunction or * failure of the Cypress product may reasonably be expected to result in * significant property damage, injury or death ("High Risk Product"). By -* including Cypress's product in a High Risk Product, the manufacturer of such -* system or application assumes all risk of such use and in doing so agrees to -* indemnify Cypress against all liability. +* including Cypress's product in a High Risk Product, the manufacturer +* of such system or application assumes all risk of such use and in doing +* so agrees to indemnify Cypress against all liability. *******************************************************************************/ -#include "cy_pdl.h" #include "cyhal.h" #include "cybsp.h" /******************************************************************************* * Macros ********************************************************************************/ -/* WDT demo options */ -#define WDT_RESET_DEMO 1 -#define WDT_INTERRUPT_DEMO 2 - -/* WDT Interrupt Number */ -#define WDT_IRQ__INTC_NUMBER srss_interrupt_IRQn -#define WDT_IRQ__INTC_CORTEXM4_PRIORITY 7 - -/* ILO Frequency in Hz */ -#define ILO_FREQUENCY_HZ 32000 - -/* WDT interrupt period in milliseconds. Max limit is 2047ms. */ -#define WDT_INTERRUPT_INTERVAL_MS 1000 - -/* Match count = Desired interrupt interval in seconds x ILO Frequency in Hz */ -#define WDT_MATCH_COUNT (WDT_INTERRUPT_INTERVAL_MS * ILO_FREQUENCY_HZ / 1000) /* WDT time out for reset mode, in milliseconds. Max limit is given by CYHAL_WDT_MAX_TIMEOUT_MS */ #define WDT_TIME_OUT_MS 4000 +#define ENABLE_BLOCKING_FUNCTION 0 /******************************************************************************* * Function Prototypes ********************************************************************************/ -void InitializeWDT(void); -void WdtInterruptHandler(void); +void initialize_wdt(void); /******************************************************************************* * Global Variables ********************************************************************************/ -/* WDT interrupt configuration structure */ -const cy_stc_sysint_t WDT_IRQ_cfg = { - .intrSrc = (IRQn_Type) WDT_IRQ__INTC_NUMBER, - .intrPriority = WDT_IRQ__INTC_CORTEXM4_PRIORITY -}; /* WDT object */ cyhal_wdt_t wdt_obj; + /******************************************************************************* * Function Name: main ******************************************************************************** * Summary: -* This is the main function for CM4 CPU. It configures the WDT in either -* reset mode or periodic interrupt mode. +* This is the main function for CM4 CPU. It demonstrates the WDT reset +* * * Parameters: * void @@ -135,34 +116,26 @@ int main(void) } /* Initialize WDT */ - InitializeWDT(); + initialize_wdt(); /* Enable global interrupt */ __enable_irq(); for (;;) { - #if (WDT_DEMO == WDT_RESET_DEMO) + #if (ENABLE_BLOCKING_FUNCTION) + while(1); + #else /* Reset WDT */ cyhal_wdt_kick(&wdt_obj); - #if defined(EXECUTION_BLOCK) - while(1); - #endif - /* Constant delay of 1000ms */ cyhal_system_delay_ms(1000); /* Invert the state of LED */ cyhal_gpio_toggle(CYBSP_USER_LED); #endif - - #if (WDT_DEMO == WDT_INTERRUPT_DEMO) - #if defined(DEEPSLEEP_ENABLE) - /* Code to demonstrate wake up from deep sleep */ - cyhal_syspm_deepsleep(); - #endif - #endif + } } @@ -179,82 +152,17 @@ int main(void) * void * *******************************************************************************/ -void InitializeWDT() +void initialize_wdt() { cy_rslt_t result; - #if (WDT_DEMO == WDT_INTERRUPT_DEMO) - - /* Step 1- Unlock WDT */ - Cy_WDT_Unlock(); - - /* Step 2- Write the ignore bits - operate with full 16 bits */ - Cy_WDT_SetIgnoreBits(0); + /* Initialize the WDT */ + result = cyhal_wdt_init(&wdt_obj, WDT_TIME_OUT_MS); - /* Step 3- Write match value */ - Cy_WDT_SetMatch(WDT_MATCH_COUNT); - - /* Step 4- Clear match event interrupt, if any */ - Cy_WDT_ClearInterrupt(); - - /* Step 5- Enable ILO */ - Cy_SysClk_IloEnable(); - - /* Step 6 - Enable interrupt if periodic interrupt mode selected */ - Cy_SysInt_Init(&WDT_IRQ_cfg, WdtInterruptHandler); - NVIC_EnableIRQ(WDT_IRQ_cfg.intrSrc); - Cy_WDT_UnmaskInterrupt(); - - /* Step 7- Enable WDT */ - Cy_WDT_Enable(); - - /* Step 8- Lock WDT configuration */ - Cy_WDT_Lock(); - #else /* Reset Demo */ - - /* Initialize the WDT */ - result = cyhal_wdt_init(&wdt_obj, WDT_TIME_OUT_MS); - - /* WDT initialization failed. Stop program execution */ - if (result != CY_RSLT_SUCCESS) - { - CY_ASSERT(0); - } - - #endif -} - -/******************************************************************************* -* Function Name: WdtInterruptHandler -******************************************************************************** -* Summary: -* This function is the handler for the WDT interrupt -* -* Parameters: -* void -* -* Return: -* void -* -*******************************************************************************/ -void WdtInterruptHandler(void) -{ - /* Check if the interrupt is from WDT */ - if (SRSS_SRSS_INTR & SRSS_SRSS_INTR_WDT_MATCH_Msk) + /* WDT initialization failed. Stop program execution */ + if (result != CY_RSLT_SUCCESS) { - /* Clear WDT Interrupt */ - Cy_WDT_ClearInterrupt(); - - /* Update the match count */ - Cy_WDT_Unlock(); - - /* Update the match count. Note that, if the ignore bits in the match is set - * to a non-zero value, the below code requires a modification. */ - Cy_WDT_SetMatch((uint16)(Cy_WDT_GetMatch() + WDT_MATCH_COUNT)); - Cy_WDT_Lock(); - - /* Invert the state of LED */ - cyhal_gpio_toggle(CYBSP_USER_LED); + CY_ASSERT(0); } }