Skip to content

Commit a1c89d4

Browse files
committed
MPAE-9711 Initial example code and readme added
1 parent 1022c32 commit a1c89d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+9691
-40
lines changed

.main-meta/main.json

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,76 @@
44
"content": {
55
"metaDataVersion": "1.1.0",
66
"name": "com.microchip.mcu8.studio.project.avr128db48-overcurrent-protection-studio-start",
7-
"version": "",
8-
"displayName": "",
7+
"version": "1.0.0",
8+
"displayName": "Overcurrent Protection Using the Integrated Op Amps on AVR DB",
99
"projectName": "avr128db48-overcurrent-protection-studio-start",
10-
"shortDescription": "",
10+
"shortDescription": "This repository provides an Atmel START project for a core independent overcurrent protection and handling with auto-calibration of current draw trigger level using the internal OPAMP, TCD and AC.",
1111
"ide": {
1212
"name": "STUDIO",
13-
"semverRange": ""
13+
"semverRange": ">=7.0.2542"
1414
},
1515
"compiler": [
1616
{
17-
"name": "",
18-
"semverRange": ""
17+
"name": "AVR GCC",
18+
"semverRange": "^5.4.0"
1919
}
2020
],
2121
"dfp": {
22-
"name": "",
23-
"semverRange": ""
22+
"name": "AVR-Dx_DFP",
23+
"semverRange": "^1.6.76"
2424
},
2525
"configurator": {
26-
"name": "",
27-
"semverRange": ""
26+
"name": "START",
27+
"semverRange": ">=1.8.491"
2828
},
2929
"device": {
3030
"metaDataVersion": "1.0.0",
3131
"category": "com.microchip.portal.contentRef",
3232
"content": {
3333
"metaDataVersion": "1.0.0",
3434
"category": "com.microchip.device",
35-
"name": "",
35+
"name": "AVR128DB48",
3636
"versionRange": "*"
3737
}
3838
},
39-
"author": "",
39+
"author": "Johan Vaarlid",
4040
"subcategories": [
41+
[
42+
"Peripherals", "OPAMP"
43+
],
44+
[
45+
"Peripherals", "AC"
46+
],
47+
[
48+
"Peripherals", "EVSYS"
49+
],
50+
[
51+
"Peripherals", "CCL"
52+
],
53+
[
54+
"Peripherals", "TCD"
55+
],
56+
[
57+
"Development Kit", "AVR128DB48 Curiosity Nano"
58+
]
4159
],
4260
"peripherals": [
43-
],
61+
62+
"OPAMP","AC","EVSYS","CCL", "TCD"
63+
],
4464
"keywords": [
45-
],
65+
"Analog Signal Conditioning",
66+
"Operational Amplifier",
67+
"Op Amp",
68+
"Resistor Ladder",
69+
"D/A Converters",
70+
"Low BOM",
71+
"CIP",
72+
"Motor Control",
73+
"Comparators",
74+
"Fan Controllers",
75+
"overcurrent-protection"
76+
],
4677
"additionalData": {
4778
"longDescription": {
4879
"metaDataVersion": "1.0.0",

README.md

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
1-
<!-- Please do not change this logo with link -->
2-
[![MCHP](images/microchip.png)](https://www.microchip.com)
1+
<!-- Please do not change this html logo with link -->
2+
<a href="https://www.microchip.com" rel="nofollow"><img src="images/microchip.png" alt="MCHP" width="300"/></a>
33

4-
# Update the title for avr128db48-overcurrent-protection-studio-start here
5-
6-
<!-- This is where the introduction to the example goes, including mentioning the peripherals used -->
4+
# AVR128DB48 Current Spike Detection
5+
A new feature introduced in the AVR® DB family is the Analog Signal Conditioning (OPAMP) peripheral. In this example, the OPAMP is used together with an Analog Comparator (AC) to form a current spike detector. The fan is enabled by a TCD waveform output. This output will be shut off automatically when the current spike is detected by the detector, making it an ideal solution for applications where functional safety is needed. As an example of an application where a current spike might indicate failure or danger, is a computer fan. Under normal operation, the current consumption is nonlinear, but does not exceed a certain threshold, dependent on the fans spec. By autotuning the gain of the internal OPAMP by using the internal resistor ladders, we can automatically boost the signal to a measurable range, and automatically set a trigger level for the AC by use of the on board DAC to define what an "unnaturally" high current consumtion is, indicating a touch or something stuck in the fan.
76

87
## Related Documentation
98

10-
<!-- Any information about an application note or tech brief can be linked here. Use unbreakable links!
11-
In addition a link to the device family landing page and relevant peripheral pages as well:
12-
- [AN3381 - Brushless DC Fan Speed Control Using Temperature Input and Tachometer Feedback](https://microchip.com/00003381/)
13-
- [PIC18F-Q10 Family Product Page](https://www.microchip.com/design-centers/8-bit/pic-mcus/device-selection/pic18f-q10-product-family) -->
9+
* [AN3860 - Overcurrent Protection Using the Integrated Op Amps on AVR® DB](https://microchip.com/DS00003860)
10+
* [AVR128DB48 device page](https://www.microchip.com/wwwproducts/en/AVR128DB48)
11+
* [AVR128DB48 Curiosity Nano User Guide](https://www.microchip.com/DS50003037)
1412

1513
## Software Used
1614

17-
<!-- All software used in this example must be listed here. Use unbreakable links!
18-
- MPLAB® X IDE 5.30 or newer [(microchip.com/mplab/mplab-x-ide)](http://www.microchip.com/mplab/mplab-x-ide)
19-
- MPLAB® XC8 2.10 or a newer compiler [(microchip.com/mplab/compilers)](http://www.microchip.com/mplab/compilers)
20-
- MPLAB® Code Configurator (MCC) 3.95.0 or newer [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
21-
- MPLAB® Code Configurator (MCC) Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
22-
- Microchip PIC18F-Q Series Device Support (1.4.109) or newer [(packs.download.microchip.com/)](https://packs.download.microchip.com/) -->
23-
15+
* [Microchip Studio](https://www.microchip.com/mplab/microchip-studio) 7.0.2542 or later
16+
* [Atmel AVR-Dx_DFP version 1.6.76](http://packs.download.atmel.com/#collapse-Atmel-AVR-Dx-DFP-pdsc) or later
17+
* For the MCC MPLAB® X version of this project, please go to [this repository](https://github.com/microchip-pic-avr-examples/avr128db48-overcurrent-protection-mplab-mcc.git)
18+
* For the Microchip Studio version of this project, please go to [this repository](https://github.com/microchip-pic-avr-examples/avr128db48-overcurrent-protection-studio.git)
2419
## Hardware Used
2520

26-
<!-- All hardware used in this example must be listed here. Use unbreakable links!
27-
- PIC18F47Q10 Curiosity Nano [(DM182029)](https://www.microchip.com/Developmenttools/ProductDetails/DM182029)
28-
- Curiosity Nano Base for Click boards™ [(AC164162)](https://www.microchip.com/Developmenttools/ProductDetails/AC164162)
29-
- POT Click board™ [(MIKROE-3402)](https://www.mikroe.com/pot-click) -->
21+
* [AVR128DB48 Curiosity Nano](https://www.microchip.com/DevelopmentTools/ProductDetails/PartNO/EV35L43A)
22+
* A small computer fan (M1)
23+
* 3x 1 kOhm resistor (R2, R3, R5)
24+
* 1x 10 kOhm resistor (R6)
25+
* 1x 0.1 Ohm current sense resistor (R1)
26+
* 2x 100nF capasitors (C1, C2)
27+
* 1x N-Channel MOSFET transistor (Q1)
28+
* 1x Signal Diode (D1)
3029

31-
## Setup
3230

33-
<!-- Explain how to connect hardware and set up software. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
3431

35-
## Operation
32+
## Setup
33+
* Hook up the circuit as shown in the figure below
34+
* For minimal noise, soldering the circuit onto a perfboard/stripboard is prefered, although a breadboard could be used with worse performance
35+
<p><img src="images/circuit_drawing.png" alt="Circuit Drawing" width="400"/></p>
3636

37-
<!-- Explain how to operate the example. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
37+
## Operation
38+
* Connect the AVR128DB48 Curiosity Nano to a computer using a USB cable
39+
* Download the zip file or clone the example to get the source code
40+
* Open the .atsln with Atmel Studio
41+
* Press *Start without debugging* or use CTRL+ALT+F5 hotkeys to run the application
42+
* After the LED stops flashing, it is done calibrating
43+
* Gently apply preassure to the fan, being very careful not to hurt yourself. The fan should now stop.
44+
* Click the onboard button (SW1) to re-enable the fan
3845

39-
## Summary
4046

41-
<!-- Summarize what the example has shown -->
47+
## Conclusion
48+
After going through this example, you should have a better understanding of how to combine the OPAMP and AC peripherals to make a current spike detector.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Atmel Studio Solution File, Format Version 11.00
4+
VisualStudioVersion = 14.0.23107.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "avr128db48-overcurrent-protection-studio-start", "avr128db48-overcurrent-protection-studio-start\avr128db48-overcurrent-protection-studio-start.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|AVR = Debug|AVR
11+
Release|AVR = Release|AVR
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR
15+
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
16+
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
17+
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<environment>
2+
<configurations>
3+
<configuration environment="Microchip Studio gcc" name="All" version="7.0.0">
4+
<linker-config>
5+
<option id="avrgcc_linker_miscellaneous_LinkerFlags" name="avrgcc-linker-miscellaneous-LinkerFlags">
6+
<value>
7+
</value>
8+
</option>
9+
</linker-config>
10+
<linker-script-config />
11+
<compiler-config>
12+
<option id="avrgcc_compiler_miscellaneous_OtherFlags" name="avrgcc-compiler-miscellaneous-OtherFlags">
13+
<value>-std=gnu99</value>
14+
</option>
15+
</compiler-config>
16+
</configuration>
17+
<configuration environment="Microchip Studio xc8" name="All" version="7.0.0">
18+
<linker-config>
19+
<option id="xc8_linker_miscellaneous_LinkerFlags" name="xc8-linker-miscellaneous-LinkerFlags">
20+
<value>
21+
</value>
22+
</option>
23+
</linker-config>
24+
<linker-script-config />
25+
<compiler-config>
26+
<option id="xc8_compiler_miscellaneous_OtherFlags" name="xc8-compiler-miscellaneous-OtherFlags">
27+
<value>-std=gnu99</value>
28+
</option>
29+
</compiler-config>
30+
</configuration>
31+
<configuration environment="Atmel Studio" name="Release" version="7.0.0">
32+
<linker-config>
33+
<option id="avrgcc_linker_miscellaneous_LinkerFlags" name="avrgcc-linker-miscellaneous-LinkerFlags">
34+
<value>
35+
</value>
36+
</option>
37+
</linker-config>
38+
<linker-script-config />
39+
<compiler-config>
40+
<option id="avrgcc_compiler_miscellaneous_OtherFlags" name="avrgcc-compiler-miscellaneous-OtherFlags">
41+
<value>-std=gnu99</value>
42+
</option>
43+
</compiler-config>
44+
</configuration>
45+
<configuration environment="Atmel Studio" name="Debug" version="7.0.0">
46+
<linker-config>
47+
<option id="avrgcc_linker_miscellaneous_LinkerFlags" name="avrgcc-linker-miscellaneous-LinkerFlags">
48+
<value>
49+
</value>
50+
</option>
51+
</linker-config>
52+
<linker-script-config />
53+
<compiler-config>
54+
<option id="avrgcc_compiler_miscellaneous_OtherFlags" name="avrgcc-compiler-miscellaneous-OtherFlags">
55+
<value>-std=gnu99</value>
56+
</option>
57+
</compiler-config>
58+
</configuration>
59+
</configurations>
60+
<device-packs>
61+
<device-pack device="AVR128DB48" name="AVR-Dx_DFP" vendor="Atmel" version="1.6.76" />
62+
</device-packs>
63+
</environment>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<package xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.0" xs:noNamespaceSchemaLocation="PACK.xsd">
2+
<vendor>Atmel</vendor>
3+
<name>avr128db48-overcurrent-protection-studio-start</name>
4+
<description>Project generated by Atmel Start</description>
5+
<url>http://start.atmel.com/</url>
6+
<releases>
7+
<release version="1.0.1">Initial version</release>
8+
</releases>
9+
<taxonomy>
10+
<description Cclass="AtmelStart" generator="AtmelStart">Configuration Files generated by Atmel Start</description>
11+
</taxonomy>
12+
<generators>
13+
<generator id="AtmelStart">
14+
<description>Atmel Start</description>
15+
<select Dname="AVR128DB48" Dvendor="Atmel:3"/>
16+
<command>http://start.atmel.com/</command>
17+
<files>
18+
<file category="generator" name="atmel_start_config.atstart"/>
19+
<file attr="template" category="other" name="AtmelStart.env_conf" select="Environment configuration"/>
20+
</files>
21+
</generator>
22+
</generators>
23+
<conditions>
24+
<condition id="AVR Device Startup">
25+
<description>Dependency on Device Startup components</description>
26+
<require Cclass="Device" Cgroup="Startup" Cversion="1.6.0"/>
27+
</condition>
28+
<condition id="ARMCC, GCC, IAR, XC8">
29+
<require Dname="AVR128DB48"/>
30+
<accept Tcompiler="ARMCC"/>
31+
<accept Tcompiler="GCC"/>
32+
<accept Tcompiler="IAR"/>
33+
<accept Tcompiler="XC8"/>
34+
</condition>
35+
</conditions>
36+
<components generator="AtmelStart">
37+
<component Cclass="AtmelStart" Cgroup="Framework" Cversion="1.0.0" condition="AVR Device Startup">
38+
<description>Atmel Start Framework</description>
39+
<RTE_Components_h>#define ATMEL_START</RTE_Components_h>
40+
<files>
41+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/generator/DoxygenLayout.xml"/>
42+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/generator/doxyfile.doxygen"/>
43+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/mainpage.dox"/>
44+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/ac/doc/ac.rst"/>
45+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/bod/doc/bod.rst"/>
46+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/ccl/doc/ccl.rst"/>
47+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/clkctrl/doc/clkctrl.rst"/>
48+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/cpuint/doc/cpuint.rst"/>
49+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/opamp/doc/opamp.rst"/>
50+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/slpctrl/doc/slpctrl.rst"/>
51+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/timer/doc/tcd.rst"/>
52+
<file category="doc" condition="ARMCC, GCC, IAR, XC8" name="modules/vref/doc/vref.rst"/>
53+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="main.c"/>
54+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/driver_init.c"/>
55+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/driver_init.h"/>
56+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/atmel_start_pins.h"/>
57+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="driver_isr.c"/>
58+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/mainpage.dox"/>
59+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/generator/doxyfile.doxygen"/>
60+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/generator/DoxygenLayout.xml"/>
61+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/ac.dox"/>
62+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/opamp.dox"/>
63+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/system.dox"/>
64+
<file category="other" condition="ARMCC, GCC, IAR, XC8" name="doxygen/timer.dox"/>
65+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/ac.h"/>
66+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/bod.h"/>
67+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/ccl.h"/>
68+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/ccp.h"/>
69+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/clkctrl.h"/>
70+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/cpuint.h"/>
71+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/opamp_basic.h"/>
72+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/port.h"/>
73+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/protected_io.h"/>
74+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/rstctrl.h"/>
75+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/slpctrl.h"/>
76+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/system.h"/>
77+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/tcd.h"/>
78+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="include/vref.h"/>
79+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/ac.c"/>
80+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/bod.c"/>
81+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/ccl.c"/>
82+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/clkctrl.c"/>
83+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/cpuint.c"/>
84+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/opamp_basic.c"/>
85+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/protected_io.S"/>
86+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/slpctrl.c"/>
87+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/tcd.c"/>
88+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="src/vref.c"/>
89+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/assembler.h"/>
90+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/assembler/gas.h"/>
91+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/assembler/iar.h"/>
92+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/atomic.h"/>
93+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/compiler.h"/>
94+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/interrupt_avr8.h"/>
95+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/utils.h"/>
96+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="utils/utils_assert.h"/>
97+
<file category="header" condition="ARMCC, GCC, IAR, XC8" name="atmel_start.h"/>
98+
<file category="source" condition="ARMCC, GCC, IAR, XC8" name="atmel_start.c"/>
99+
<file attr="config" category="header" condition="ARMCC, GCC, IAR, XC8" name="config/clock_config.h"/>
100+
<file category="include" condition="ARMCC, GCC, IAR, XC8" name="config"/>
101+
<file category="include" condition="ARMCC, GCC, IAR, XC8" name="include"/>
102+
<file category="include" condition="ARMCC, GCC, IAR, XC8" name="utils"/>
103+
<file category="include" condition="ARMCC, GCC, IAR, XC8" name="utils/assembler"/>
104+
<file category="include" condition="ARMCC, GCC, IAR, XC8" name=""/>
105+
</files>
106+
</component>
107+
</components>
108+
</package>

0 commit comments

Comments
 (0)