# Project Name：Adc_Dma_Demo

---
## Function description

This project is designed to demonstrate the MCAL Adc module configuration and usage:
- **Adc**: 
  - There are two groups configured in the demo. All groups configured transfer results with DMA. The detail information of each group is as follows:

|Group Name|Transfer Type|Trigger Type|Conversion and Access Mode|Channel List|
|----|----|----|----|----|
|AdcGroup0|DMA|Software|Continuous conversion and single access|ADC0_SE0, ADC0_SE1, PMC VREF,TEMP,VREFH,PMC VREFH,ADC0_SE0|
|AdcGroup1|DMA|Software|Continuous conversion and circular streaming|ADC0_SE0, ADC0_SE1|

After reset, the demo project will initialize the Adc driver, setup result buffers for all group, enable notification for the necessary groups, and start all group to conversion. The groups operated as following:
  - **AdcGroup0:** Read the results in while(1),and auto restart the group conversion after reading results.
  - **AdcGroup1:** Read the results in callback notification, and auto restart the group conversion after read results.
  - The SE0_ADCH0 channel conversion results from all groups are mutually checked repeatedly.

This demo code defines the following variables to observe the acquisition results and the program's running status:
- **Variables for ADC Conversion Results**
  - `Adc_Group0An0PhyValue`: The physical value of the ADC0_SE0 channel conversion result in AdcGroup0, with the unit in millivolts.
  - `Adc_Group0An1PhyValue`: The physical value of the ADC0_SE1 channel conversion result in AdcGroup0, with the unit in millivolts.
  - `Adc_Group1An0PhyValue`: The physical value of the ADC0_SE0 channel conversion result in AdcGroup1, with the unit in millivolts.
  - `Adc_Group1An1PhyValue`: The physical value of the ADC0_SE1 channel conversion result in AdcGroup1, with the unit in millivolts.
  - `Adc_McuPmcVrefValue`: The physical value of the PMC VREF channel conversion result  in AdcGroup0, with the unit in millivolts.
  - `Adc_McuVrefhValue`: The physical value of the VREFH channel conversion result in AdcGroup0, with the unit in millivolts.
- **Variables for Counting Conversion Times**
  - `Adc_Group0ConCompCnt`: Counts the number of completed conversions for AdcGroup0.
  - `Adc_Group1ConCompCnt`: Counts the number of completed conversions for AdcGroup1.
  - `Adc_RstDiffOverFlowCnt`: The program checks the correctness of the ADC0 channel 0 conversion results among different groups. Specifically, it compares the results of AdcGroup0 with those of AdcGroup1. If the difference between the results of Group 0 and another group exceeds 100mV, the `Adc_RstDiffOverFlowCnt` variable is incremented.

- **Expected values for the conversion results of each Channel** (VDD supply voltage is 5V):

|Channel|Description |Expected Value (mV)|
|----|----|----|
|ADC0_SE0~ADC0_SE1|ADC0 external input channels  |External input value  |
|PMC VREF|PMC 1.2V reference voltage  |1200  |
|VREFH|VREFH voltage value |5000  |
|TEMP|MCU internal temperature sensor  |Uncertain values, related to the ambient temperature |

**Note**: In this Demo, the MCU is powered by 5V. If you need to use 3.3V power supply, please modify the calculation of the physical values of the ADC conversion results by yourself.

---


## Setup

+ ***Step1***: Open the `Adc_Dma_Demo.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.
  

---

## 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***.

---