# Project Name: Icu_Demo
---
## Function Description

This demonstration captures the PWM period and duty cycle time of the IO input through the comparison input function and port input capture function of ETMR. The PWM output signal is generated by ETMR0_CH0, and the input signal is captured by ETMR0_CH1. The period and duty cycle of the input signal are calculated through the input capture function of ETMR0_CH1.

---
## Setup Procedure

+ ***Step 1***: Open the `Icu_Demo_RevA.yct` with the YCT tool and configure the toolchain according to your requirements (by default, VS Code + GCC are used).
+ ***Step 2***: Generate the code. You can modify the configurations if needed (to adapt to your own hardware design). Ensure all modifications are error-free before generating the code.
+ ***Step 3***: Open the generated project with the selected IDE (VS Code/IAR/Keil).
+ ***Step 4***: Compile the project, power on the EVB, and download it to the EVB using the available debugger, such as a J-Link debugger probe.
+ ***Step 5***: Connect eTMR0_CH0 <-> eTMR0_CH4. Press SW2 and SW3 respectively to trigger the Port edge detection, and then start to capture the period and duty cycle of the input signal.
+ ***Step 6***: Add `Dbg_MeasureDutyCycleValue_Ch` to your watch window and check the period and duty cycle of the input signal.
---
## ICU Hardware Connection Diagram
| Function | MCU Pin | EVB Pin Header | Description |
| -------- | ------- | -------------- | ----------- |
| eTMR0_CH0 <-> eTMR0_CH4 | PTB16 <-> PTB12 | H3-14P <-> H3-18P | eTMR0_CH4 (ICU) input captures eTMR0_CH0 (PWM) output compare |
---
## Hardware requirement
+ **EVB**: YTM32B1MD1-EVB-Q100-Rev.A/B
+ **Debugger**: J-Link HW v9 or later with YUNTU `YTM32B1MD1` patch(support package) installed.

**Note**: Please check the version number at the bottom of the EVB. If it is `YTM32B1MD1-EVB-Q100-Rev.A/B`, please use the example projects ending with `_RevA` for `Icu_Demo`.
---

## Software requirement

+ **Config & Code Generation Tool**
  + **MCAL**: Yuntu Config Tool(YCT) v2.7.0 or later version
+ **Compiler Toolchain**
  + **GCC**: GNU GCC v10.3 or later version
  + **Keil/MDK**: ARM Keil/MDK v5.36 or later version(`armclang v6.18.2` is recommended to be used as the compiler)
  + **IAR**: IAR v9.50 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 J-Link v7.82 or later version, YUNTU `YTM32B1MD1` patch(support package) installation required.
    + **Ozone Debugger tool**: SEGGER Ozone v3.28 or later version.

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

---