Skip to content

Commit dfcad57

Browse files
author
Microchip Technology
committed
Added 2 projects ADC Sampling and IIR Filtering and ADC Sampling and FIR Filtering
1 parent 59ddd49 commit dfcad57

File tree

38 files changed

+6816
-9
lines changed

38 files changed

+6816
-9
lines changed

.main-meta/main.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"content":{
55
"metaDataVersion":"1.3.0",
66
"name":"com.microchip.mplabx.project.pic24e-dspic33e-code-examples",
7-
"version":"x.x.x",
8-
"displayName":"xxxxxxxxxxxxxxx",
7+
"version":"1.0.0",
8+
"displayName":"PIC24E/DSPIC33E Code Examples",
99
"projectName":"pic24e-dspic33e-code-examples",
10-
"shortDescription":"xxxxxxxxxxxxxxx",
10+
"shortDescription":"PIC24E/DSPIC33E Code Examples",
1111
"ide":{
1212
"name":"MPLABX",
1313
"semverRange":">=5.40.0"
@@ -17,8 +17,8 @@
1717
"semverRange":"^1.50.0"
1818
},
1919
"dfp":{
20-
"name":"xxxxxxxxxxxxxxx",
21-
"semverRange":">=x.x.x"
20+
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
21+
"semverRange":">=1.3.85"
2222
},
2323
"configurator": {
2424
"name": "MCC",
@@ -30,16 +30,17 @@
3030
"content":{
3131
"metaDataVersion":"1.0.0",
3232
"category":"com.microchip.device",
33-
"name":"xxxxxxxxxxxxxxx",
33+
"name":"DSPIC33EP512GM710,DSPIC33EP512MU810,DSPIC33EP256GP506",
3434
"versionRange":"*"
3535
}
3636
},
3737
"peripherals":[
38-
"GPIO",
38+
"ADC",
3939
],
4040
"keywords":[
41-
"GPIO",
42-
"UART"
41+
"ADC",
42+
"Filter",
43+
"Signal Sampling"
4344
]
4445
}
4546
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"metaDataVersion":"1.0.0",
3+
"category":"com.microchip.ide.project",
4+
"content":{
5+
"metaDataVersion":"1.3.0",
6+
"name":"com.microchip.mplabx.project.ce400-adc-iir-filter",
7+
"version":"1.0.0",
8+
"displayName":"ADC Sampling and IIR Filtering",
9+
"projectName":"ce400-adc-iir-filter",
10+
"shortDescription":"ADC Sampling and IIR Filtering",
11+
"ide":{
12+
"name":"MPLABX",
13+
"semverRange":">=5.50.0"
14+
},
15+
"compiler":{
16+
"name":"XC16",
17+
"semverRange":"^1.70.0"
18+
},
19+
"dfp":{
20+
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
21+
"semverRange":">=1.3.85"
22+
},
23+
"configurator": {
24+
"name": "MCC",
25+
"semverRange": ">=4.0.1"
26+
},
27+
"device":{
28+
"metaDataVersion":"1.0.0",
29+
"category":"com.microchip.portal.contentRef",
30+
"content":{
31+
"metaDataVersion":"1.0.0",
32+
"category":"com.microchip.device",
33+
"name":"DSPIC33EP512GM710,DSPIC33EP512MU810,DSPIC33EP256GP506",
34+
"versionRange":"*"
35+
}
36+
},
37+
"peripherals":[
38+
"ADC",
39+
],
40+
"keywords":[
41+
"ADC",
42+
"Filter",
43+
"Signal Sampling",
44+
"Algorithm"
45+
]
46+
}
47+
}

ce400-adc-iir-filter/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
![image](../images/microchip.jpg)
2+
3+
## ADC Sampling and IIR Filtering
4+
5+
This file contains the following sections:
6+
- Code Example Description
7+
- Hardware Used
8+
- Software Used
9+
- Reconfiguring the project for a different dsPIC33E device
10+
- Revision History
11+
12+
13+
## Description:
14+
15+
In this example, ADC is configured to sample (AIN5) at 8Khz rate and converted data is assembled as 256 sample buffer before triggering filtering operation.
16+
17+
Timer 3 is setup to time-out every 125 microseconds (8Khz Rate).
18+
As a result, the module will stop sampling and trigger a 12-bit A/D conversion on every Timer3 time-out, i.e., Ts=125us.
19+
At that time, the conversion process starts and completes Tc=14*Tad periods later.
20+
When the conversion completes, the module starts sampling again. However, since Timer3
21+
is already on and counting, about (Ts-Tc)us later, Timer3 will expire again and trigger
22+
next conversion.
23+
24+
ADC module clock time period is configured as Tad=Tcy*(ADCS+1)= (1/40M)*64 = 1.6us (625Khz).
25+
Hence the conversion time for 12-bit A/D Conversion Time Tc=14*Tad = 22.4us
26+
27+
void initTmr3();
28+
Timer 3 is configured to time-out at 8Khz rate.
29+
30+
void initAdc1(void);
31+
ADC module is set-up to convert AIN5 input using CH0 S/H on Timer 3 event in 12-bit mode.
32+
33+
void initDma0(void);
34+
DMA channel 0 is configured in ping-pong mode to move the converted data from ADC to DMA RAM on every sample/convert sequence.
35+
It generates interrupt after every 256 sample transfer.
36+
37+
void __attribute__((__interrupt__)) _DMA0Interrupt(void);
38+
DMA interrupt service routine performs IIR filtering on the data buffer.
39+
40+
41+
## Hardware Used
42+
43+
- Explorer 16/32 Development Board (https://www.microchip.com/DM240001-2)
44+
- dspic33ep512gm710(https://www.microchip.com/ma330035) /dspic33ep512mu810 (https://www.microchip.com/MA330025-1)/ dspic33ep256gp506 (https://www.microchip.com/MA330030) PIM
45+
46+
## Software Used
47+
48+
- MPLAB® X IDE v5.50 or newer (https://www.microchip.com/mplabx)
49+
- MPLAB® XC16 v1.70 or newer (https://www.microchip.com/xc)
50+
51+
52+
## Reconfiguring the project for a different dsPIC33E device:
53+
54+
The Project/Workspace can be easily reconfigured for dspic33ep512gm710/dspic33ep512mu810/dspic33ep256gp506 device.
55+
Please use the following general guidelines:
56+
57+
a. Change device selection within MPLAB® IDE to dspic33ep512gm710/dspic33ep512mu810/dspic33ep256gp506 device of
58+
your choice by using the following menu option:
59+
MPLAB X>>Configuration drop-down option>><Listed Device Configuration>
60+
61+
b. Re-build the MPLAB® project using the menu option:
62+
MPLAB X>>Build Main Project
63+
64+
c. Download the hex file into the device and run.
65+
66+
67+
## Revision History :
68+
69+
04/01/2006 - Initial Release of the Code Example
70+
7/01/2010 - Code Example updated for dsPIC33E
71+
1/22/2014 - Code Example updated for dspic33ep512gm710/dspic33ep512mu810/dspic33ep256gp506
72+
01/08/2015 - TEST_MODE code added for test automation
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

0 commit comments

Comments
 (0)