Skip to content

Commit 0edf866

Browse files
committed
MPAE-5989 Added MPLABX project, Readme and meta data
1 parent 333dfab commit 0edf866

File tree

7 files changed

+652
-45
lines changed

7 files changed

+652
-45
lines changed

.main-meta/main.json

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
"metaDataVersion": "1.1.0",
66
"name": "com.microchip.mcu8.mplabx.project.avr128db48-constant-current-driver-using-opamp-mplab",
77
"version": "1.0.0",
8-
"displayName": "AVR128DB48 constant current driver using opamp mplab",
8+
"displayName": "Constant-Current Driver Using the Analog Signal Conditioning (OPAMP) Peripheral",
99
"projectName": "avr128db48-constant-current-driver-using-opamp-mplab",
10-
"shortDescription": "",
10+
"shortDescription": "This MPLAB X bare metal example in Constant-Current Driver Using the Analog Signal Conditioning (OPAMP) Peripheral (AN3632), shows how to use the OPAMP to implement a constant-current driver using just one external resistor. The OPAMP peripheral also provides the ability to adjust the current setting under firmware control.",
1111
"ide": {
12-
"name": "MPLABX",
13-
"semverRange": ""
12+
"name": "MPLAB X",
13+
"semverRange": ">=5.40"
1414
},
1515
"compiler": [
1616
{
1717
"name": "XC8",
18-
"semverRange": ""
18+
"semverRange": "^2.20"
1919
}
2020
],
2121
"dfp": {
22-
"name": "",
23-
"semverRange": ""
22+
"name": "AVR-Dx_DFP",
23+
"semverRange": "^1.4.75"
2424
},
25-
"configurator": {
26-
"name": "",
25+
"configurator": {
26+
"name": "N/A",
2727
"semverRange": ""
2828
},
2929
"device": {
@@ -36,25 +36,34 @@
3636
"versionRange": "*"
3737
}
3838
},
39-
"author": "",
39+
"author": "Microchip",
4040
"subcategories": [
41-
"",
42-
[
43-
"Peripherals",
44-
""
41+
[
42+
"Peripherals", "OPAMP"
4543
],
4644
[
47-
"Peripherals",
48-
""
49-
]
45+
"Peripherals", "DAC"
46+
],
47+
[
48+
"Development Kit", "AVR128DB48 Curiosity Nano"
49+
]
5050
],
5151
"peripherals": [
52-
"",
53-
""
52+
"OPAMP", "DAC"
5453
],
5554
"keywords": [
56-
"",
57-
""
55+
"Analog Signal Conditioning",
56+
"Operational Amplifier",
57+
"Op Amp",
58+
"Resistor Ladder",
59+
"Constant Current",
60+
"Current Driver",
61+
"Digital-To-Analog Converter",
62+
"Low BOM",
63+
"CIP",
64+
"AVR-DB",
65+
"AVRDB",
66+
"constant-current-driver-using-opamp"
5867
],
5968
"additionalData": {
6069
"longDescription": {

README.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
1-
<!-- Please do not change this logo with link -->
2-
[![MCHP](images/microchip.png)](https://www.microchip.com)
31

4-
# Update the title for avr128db48-constant-current-driver-using-opamp-mplab here
2+
<a href="https://www.microchip.com" rel="nofollow"><img src="images/microchip.png" alt="MCHP" width="300"/></a>
53

6-
<!-- This is where the introduction to the example goes, including mentioning the peripherals used -->
4+
# Constant-Current Driver Using the Analog Signal Conditioning (OPAMP) Peripheral
5+
<p align="left">
6+
<img width=800px height=auto src="images/setup.png">
7+
</p>
8+
9+
A new feature introduced in the AVR® DB MCU is the Analog Signal Conditioning (OPAMP) peripheral. In this example, the OPAMP is used as a constant-current driver using a single external resistor. It can be used to drive a load such as LEDs, with constant current and not constant voltage. The OPAMP peripheral also provides the ability to adjust the current setting under firmware control. The configuration for this example can be seen in the figure above. For more information about setup and code, see the [application note](https://microchip.com/DS00003632).
710

811
## Related Documentation
912

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) -->
13+
* [AN3632 - Constant-Current Driver Using the Analog Signal Conditioning (OPAMP) Peripheral](https://microchip.com/DS00003632)
14+
* [AVR128DB48 Curiosity Nano User Guide](https://www.microchip.com/DS50003037)
15+
* [AVR128DB48 Device Page](https://www.microchip.com/wwwproducts/en/AVR128DB48)
1416

1517
## Software Used
1618

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-
19+
* [MPLAB® X](https://www.microchip.com/mplab/mplab-x-ide) v5.40 or later
20+
* [MPLAB® XC8 Compiler](https://www.microchip.com/mplab/compilers) v2.20 or later
21+
* MPLABX AVR-Dx_DFP version 1.4.75 or later
22+
* For the Atmel Studio version of this project, please go to [this repository](https://github.com/microchip-pic-avr-examples/avr128db48-constant-current-driver-using-opamp)
23+
2424
## Hardware Used
2525

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) -->
26+
* [AVR128DB48 Curiosity Nano](https://www.microchip.com/DevelopmentTools/ProductDetails/PartNO/EV35L43A)
27+
* One resistor (value dependent on desired current)
28+
* Load (LED, etc)
3029

3130
## Setup
3231

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 -->
32+
* Connect the hardware together as seen in the schematic of the application note
3433

3534
## Operation
35+
* Connect the AVR128DB48 Curiosity Nano to a computer using a USB cable
36+
* Download the zip file or clone the example to get the source code
37+
* Open `avr128db48-constant-current-driver-using-opamp.X` in MPLAB
38+
* Press the make and program button to program the device
39+
* If no tool has been chosen, a window will open, select the AVR128DB48 Curiosity Nano. Tool can also be choosen in the project settings.
3640

37-
<!-- Explain how to operate the example. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
38-
39-
## Summary
41+
## Conclusion
42+
After going through this example you should have a better understanding of how to set up the OPAMP peripheral as a constant current driver for a load.
4043

41-
<!-- Summarize what the example has shown -->
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#
2+
# There exist several targets which are by default empty and which can be
3+
# used for execution of your targets. These targets are usually executed
4+
# before and after some main targets. They are:
5+
#
6+
# .build-pre: called before 'build' target
7+
# .build-post: called after 'build' target
8+
# .clean-pre: called before 'clean' target
9+
# .clean-post: called after 'clean' target
10+
# .clobber-pre: called before 'clobber' target
11+
# .clobber-post: called after 'clobber' target
12+
# .all-pre: called before 'all' target
13+
# .all-post: called after 'all' target
14+
# .help-pre: called before 'help' target
15+
# .help-post: called after 'help' target
16+
#
17+
# Targets beginning with '.' are not intended to be called on their own.
18+
#
19+
# Main targets can be executed directly, and they are:
20+
#
21+
# build build a specific configuration
22+
# clean remove built files from a configuration
23+
# clobber remove all built files
24+
# all build all configurations
25+
# help print help mesage
26+
#
27+
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28+
# .help-impl are implemented in nbproject/makefile-impl.mk.
29+
#
30+
# Available make variables:
31+
#
32+
# CND_BASEDIR base directory for relative paths
33+
# CND_DISTDIR default top distribution directory (build artifacts)
34+
# CND_BUILDDIR default top build directory (object files, ...)
35+
# CONF name of current configuration
36+
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
37+
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
38+
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
39+
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
40+
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
41+
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
42+
#
43+
# NOCDDL
44+
45+
46+
# Environment
47+
MKDIR=mkdir
48+
CP=cp
49+
CCADMIN=CCadmin
50+
RANLIB=ranlib
51+
52+
53+
# build
54+
build: .build-post
55+
56+
.build-pre:
57+
# Add your pre 'build' code here...
58+
59+
.build-post: .build-impl
60+
# Add your post 'build' code here...
61+
62+
63+
# clean
64+
clean: .clean-post
65+
66+
.clean-pre:
67+
# Add your pre 'clean' code here...
68+
# WARNING: the IDE does not call this target since it takes a long time to
69+
# simply run make. Instead, the IDE removes the configuration directories
70+
# under build and dist directly without calling make.
71+
# This target is left here so people can do a clean when running a clean
72+
# outside the IDE.
73+
74+
.clean-post: .clean-impl
75+
# Add your post 'clean' code here...
76+
77+
78+
# clobber
79+
clobber: .clobber-post
80+
81+
.clobber-pre:
82+
# Add your pre 'clobber' code here...
83+
84+
.clobber-post: .clobber-impl
85+
# Add your post 'clobber' code here...
86+
87+
88+
# all
89+
all: .all-post
90+
91+
.all-pre:
92+
# Add your pre 'all' code here...
93+
94+
.all-post: .all-impl
95+
# Add your post 'all' code here...
96+
97+
98+
# help
99+
help: .help-post
100+
101+
.help-pre:
102+
# Add your pre 'help' code here...
103+
104+
.help-post: .help-impl
105+
# Add your post 'help' code here...
106+
107+
108+
109+
# include project implementation makefile
110+
include nbproject/Makefile-impl.mk
111+
112+
# include project make variables
113+
include nbproject/Makefile-variables.mk
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* \file main.c
3+
*
4+
* \brief avr128db48-constant-current-driver-using-opamp
5+
*
6+
* (c) 2020 Microchip Technology Inc. and its subsidiaries.
7+
*
8+
* Subject to your compliance with these terms,you may use this software and
9+
* any derivatives exclusively with Microchip products.It is your responsibility
10+
* to comply with third party license terms applicable to your use of third party
11+
* software (including open source software) that may accompany Microchip software.
12+
*
13+
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
14+
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
15+
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
16+
* PARTICULAR PURPOSE.
17+
*
18+
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
19+
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
20+
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
21+
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
22+
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
23+
* ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
24+
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
25+
*/
26+
27+
#include <avr/io.h>
28+
29+
// To compile the fuse configuration, the FUSES macro is used. The fuse settings are set to the device production values.
30+
FUSES = {
31+
.WDTCFG = FUSE_WDTCFG_DEFAULT,
32+
.BODCFG = FUSE_BODCFG_DEFAULT,
33+
.OSCCFG = FUSE_OSCCFG_DEFAULT,
34+
.SYSCFG0 = FUSE_SYSCFG0_DEFAULT,
35+
.SYSCFG1 = FUSE_SYSCFG1_DEFAULT,
36+
.CODESIZE = FUSE_CODESIZE_DEFAULT,
37+
.BOOTSIZE = FUSE_BOOTSIZE_DEFAULT,
38+
};
39+
// To compile the lockbits configuration, the LOCKBITS macro is used. The lockbits are set to unlocked.
40+
LOCKBITS = {
41+
LOCKBITS_DEFAULT,
42+
};
43+
44+
int main(void)
45+
{
46+
// Set up the timebase of the OPAMP peripheral
47+
OPAMP.TIMEBASE = 3; // Number of CLK_PER cycles that equal one us, minus one (4-1=3)
48+
49+
//Connect OP0 to wiper and pin connected to sense resistor
50+
OPAMP.OP0INMUX = OPAMP_OP0INMUX_MUXPOS_WIP_gc | OPAMP_OP0INMUX_MUXNEG_INN_gc;
51+
//Connect resistor ladder to VDD and ground so the wiper functions as a voltage divider
52+
OPAMP.OP0RESMUX = OPAMP_OP0RESMUX_MUXBOT_GND_gc | OPAMP_OP0RESMUX_MUXWIP_WIP7_gc | OPAMP_OP0RESMUX_MUXTOP_VDD_gc;
53+
// Configure OP0 Control A
54+
OPAMP.OP0CTRLA = OPAMP_OP0CTRLA_OUTMODE_NORMAL_gc | OPAMP_ALWAYSON_bm;
55+
56+
// Enable the OPAMP peripheral
57+
OPAMP.CTRLA = OPAMP_ENABLE_bm;
58+
59+
while (1);
60+
}
61+

0 commit comments

Comments
 (0)