1 Star 0 Fork 0

microchip-pic-avr-examples/avr128da48-using-12-bit-adc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

MCHP

Using 12-bit ADC for Conversions, Accumulation, and Triggering Events

This repository contains examples of bare metal source code for DAC as described in "Using 12-bit ADC for Conversions, Accumulation, and Triggering Events" document from Microchip. The repository contains an Atmel Studio Solution with multiple projects inside.

Use Cases:

  1. ADC Differential Conversion
  2. ADC Event Triggered
  3. ADC Free Running
  4. ADC Sample Accumulator
  5. ADC Single Conversion
  6. ADC Temperature Measurement
  7. ADC Window Comparator

Related Documentation

More details and code examples on the AVR128DA48 can be found at the following links:

Software Used

Hardware Used

Setup

The AVR128DA48 Curiosity Nano Development Board is used as test platform, inserted into the Curiosity Nano Base.

Two setups will be used for the use cases described in this document:

  • The Hardware Configuration A uses a POT click, inserted in mikroBUS slot 1, connects AN1 to the PD3(AIN3) pin of AVR® DA microcontroller.


The following configurations must be made for Hardware Configuration A:

Pin Configuration
PD3 (AIN3) Analog Input
PC6 (LED0) Digital Output

  • The Hardware Configuration B uses two POT clicks, inserted in mikroBUS slot 1 and slot 2. Slot 1 connects AN1 to the PD3 (AIN3) and slot 2 connects AN2 to PD4 (AIN4) pin of the AVR® DA microcontroller.


The following configurations must be made for Hardware Configuration B:

Pin Configuration
PD3 (AIN3) Analog Input
PD4 (AIN4) Analog Input
PC6 (LED0) Digital Output

Operation

ADC Differential Conversion

This example will initialize the ADC, configure two pins for reading the differential voltage, start the conversion and read the ADC result in an infinite loop.

The Hardware Configuration B will be used for this example

  1. Connect the board to the PC.
  2. Open the AVRDA_ADC_Examples.atsln solution in Atmel Studio
  3. Set ADC_Differential_Conversion project as StartUp project:
  4. Build the ADC_Differential_Conversion project: right click on ADC_Differential_Conversion and select Build
  5. Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the AVR-Dx_Bootloader project settings:
    • Right click on the project and click Properties;
    • Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
  6. Select Debug → Start Debugging and Break (Alt+F5)
    • Add a brake point on adcVal in the main function
  7. Result: Rotating the Potentiometers on the POT click boards (while pressing F5 key), the adcVal result will vary from a positive to a negative value:

ADC Event Triggered

This example will initialize the ADC and Real-Time Counter (RTC), configure the Event System (EVSYS) to trigger an ADC conversion on the RTC overflow; an LED is toggled on after each ADC conversion.

The Hardware Configuration A will be used for this example

  1. Connect the board to the PC.
  2. Open the AVRDA_ADC_Examples.atsln solution in Atmel Studio
  3. Set ADC_Event_Triggered project as StartUp project
  4. Right click on ADC_Event_Triggered and select Build
  5. Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the AVR-Dx_Bootloader project settings:
    • Right click on the project and click Properties;
    • Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
  6. Result: The LED0 will toggle with a frequency of RTC_PERIOD, that can be modified

ADC Free Running

This example will Initialize the ADC, enable Free Running mode, start the conversion and read the ADC result in an infinite loop.

The Hardware Configuration A will be used for this example

  1. Connect the board to the PC.
  2. Open the AVRDA_ADC_Examples.atsln solution in Atmel Studio
  3. Set ADC_Free_Running project as StartUp project
  4. Right click on ADC_Free_Running and select Build
  5. Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the AVR-Dx_Bootloader project settings:
    • Right click on the project and click Properties;
    • Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
  6. Select Debug → Start Debugging and Break (Alt+F5)
    • Add a brake point on adcVal in the main function
  7. Result: Rotating the Potentiometer on the POT click board (while pressing F5 key ), the adcVal result will vary:

ADC Sample Accumulator

This example will Initialize the ADC, enable accumulation of 64 samples, start the conversion and read the ADC result in a loop.

The Hardware Configuration A will be used for this example

  1. Connect the board to the PC.
  2. Open the AVRDA_ADC_Examples.atsln solution in Atmel Studio
  3. Set ADC_Sample_Accumulator project as StartUp project
  4. Right click on ADC_Sample_Accumulator and select Build
  5. Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the AVR-Dx_Bootloader project settings:
    • Right click on the project and click Properties;
    • Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
  6. Select Debug → Start Debugging and Break (Alt+F5)
    • Add a brake point on adcVal in the main function
  7. Result: Rotating the Potentiometer on the POT click board (while pressing F5 key), the adcVal result will vary:

ADC Single Conversion

This example will initialize the ADC, start the conversion and wait until it is completed, and read ADC result in a loop.

The Hardware Configuration A will be used for this example

  1. Connect the board to the PC.
  2. Open the AVRDA_ADC_Examples.atsln solution in Atmel Studio
  3. Set ADC_Single_Conversion project as StartUp project
  4. Right click on ADC_Single_Conversion and select Build
  5. Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the AVR-Dx_Bootloader project settings:
    • Right click on the project and click Properties;
    • Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
  6. Select Debug → Start Debugging and Break (Alt+F5)
    • Add a brake point on adcVal in the main function
  7. Result: Rotating the Potentiometer on the POT click board (while pressing F5 key), the adcVal result will vary:

ADC Temperature Measurement

This example will initialize the ADC, select the temperature sensor as input and acquire the data by running a 12-bit, right adjusted, single-ended conversion.

The Hardware Configuration A will be used for this example

  1. Connect the board to the PC.
  2. Open the AVRDA_ADC_Examples.atsln solution in Atmel Studio
  3. Set ADC_Temperature_Measurement project as StartUp project
  4. Right click on ADC_Temperature_Measurement and select Build
  5. Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the AVR-Dx_Bootloader project settings:
    • Right click on the project and click Properties;
    • Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
  6. Select Debug → Start Debugging and Break (Alt+F5)
    • Add a brake point on temp_C in the main function
  7. Result: Pressing the F5 key, the temp_C Value will show the ambient temperature in Celsius (25°C):

ADC Window Comparator

This example will set the conversion window comparator low threshold, enable the conversion Window mode, enable the Free Running mode, start the conversion and wait until it is completed, read the ADC result in an infinite loop, an LED is toggled on if the ADC result is below the set threshold.

The Hardware Configuration A will be used for this example

  1. Connect the board to the PC.
  2. Open the AVRDA_ADC_Examples.atsln solution in Atmel Studio
  3. Set ADC_Window_Comparator project as StartUp project
  4. Right click on ADC_Window_Comparator and select Build
  5. Select the AVR128DA48 Curiosity Nano on-board debugger in the Tool section of the AVR-Dx_Bootloader project settings:
    • Right click on the project and click Properties;
    • Click Tool tab on the left panel, select the corresponding debugger and save the configuration (Ctrl + S)
  6. Result: Rotating the Potentiometer on the POT click board will modify the adcVal untill LED0 will turn off:

Summary

The *TB3245 - Using 12-Bit ADC for Conversions, Accumulation, and Triggering Events document provides seven use cases for using the 12-bit ADC of The AVR® DA family of microcontrollers.

空文件

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/microchip-pic-avr-examples/avr128da48-using-12-bit-adc.git
git@gitee.com:microchip-pic-avr-examples/avr128da48-using-12-bit-adc.git
microchip-pic-avr-examples
avr128da48-using-12-bit-adc
avr128da48-using-12-bit-adc
master

搜索帮助