# Ewdg Example Code

## Project Name: Ewdg

---

## Function description

This project is designed to demonstrate the ewdg module config and usage:
- **Ewdg**: 
  - Connect PTE_8 and PTA_2, and read the level of PTA_2(ewdg_out_b) through PTE_8;
  - Example Enable the ewdg to be interrupted and initialize the ewdg module;
  - When the dog is fed within the timeout period, ewdg_out_b outputs a high level;
  - Waiting timeout;
  - Ewdg generates an interruption, and ewdg_out_b outputs a low level.

---

## HW requirement
+ **EVB**: YTM32B1MC0-EVB-Q64
+ **Debugger**: J-LINK v9.2 or later with YUNTU YTM32B1MC0 patch(support package) installed.

---

## SW requirement

+ **Config & Code Generation Tool**
  + **SDK**:       Yuntu Config Tool(YCT) v2.6.3 or later version
+ **Compiler Toolchain**
  + **GCC***     : GNU GCC v10.3 or later version
  + **Keil/MDK***: ARM Keil/MDK v5.36 or later version
  + **IAR***     : IAR v8.4 or later version
  + **VS Code**  : Microsoft Visual Studio Code IDE v1.76 or later version(C/C++ support, GNU toolchain, CMake v3.25, ninja, Cortex-Debug extensions installation required)
+ **Debugger driver**
    + **J-LINK***              : SEGGER JLINK v6.96 or later version, YUNTU YTM32B1MC0 patch(support package) installation required.
    + **Ozone Debugger tool**  : SEGGER Ozone v3.28 or later version.

    ***Note***: * **YTM32B1MC0** patch install required which can be obtained via **YCT** or contact ***YUNTU sales/FAE team***.

---

## Setup

+ ***Step1***: Open the project.yct with the YCT tool, config the toolchain per your required(by default, the VS code + GCC are used)
+ ***Step2***: Generate the codes, you can change the configurations if needed(to adapt to your own HW design), if so, please ensure all the modifications are OK with no any errors exist before generating the code.
+ ***Step3***: Open the generated project with VS code/IAR/Keil IDE per your selected.
+ ***Step4***: Compile the project, power on the EVB and download it to the EVB via the available debugger, such as a J-LINK debugger probe.
+ ***Step5***: At last, enjoy the demo example.
  
---

1. Config alt value 
   - PTC_9 Pin with Uart1_TX as TX pin 
   - PTC_8 Pin with Uart1_RX as RX pin
   - PTA_2 Pin with EWDG_OUT_b as EWDG_OUT_b pin.
   - PTE_8 Pin with gpio input as gpio_con_out pin.
   - PTA_3 Pin with EWDG_IN as EWDG_IN pin.
   - PTB_4 Pin with gpio output as gpio_con_in pin.
2. Enable and config Uart1_CLK and EWDG0_CLK.
3. Enable and config Uart、Ewdg and Utility Print module.
4. Ewdg function demonstration.
  - Connect PTB_4 and PTA_3, and PTA_3(ewdg_in) input single from PTB_4;
  - Connect PTE_8 and PTA_2, and read the level of PTA_2(ewdg_out_b) through PTE_8;
  - Example Enable the ewdg to be interrupted and initialize the ewdg module;
  - When EWDG_IN input high single and the dog is fed within the timeout period, ewdg_out_b outputs a high level, Waiting timeout, Ewdg generates an interruption, and ewdg_out_b outputs a low level.
  - Re-init EWDG, when EWDG_IN input low single and the dog is fed within the timeout period, Ewdg generates an interruption, and ewdg_out_b outputs a low level.
5. Output prompt message.
  
---