Skip to content

Commit 46b8632

Browse files
jasminefranciscaharishagari
authored andcommitted
Pull request #15: CITD-425:dspic33e-code-examples set 1
Merge in MCU16CE/dspic33e-code-examples from ~I62773/dspic33e-code-examples:feature/CITD-425-code-examples-1 to develop * commit '920bab778bc42a1b927be24f5109fc8f68a1fe8e': Updated review comments Updated review comments Addressed review comments Addressed review comments Addressed review comments Addressed review comments CITD-425:Updated content version CITD-425:code-examples
2 parents 49feda7 + 920bab7 commit 46b8632

File tree

149 files changed

+23985
-76
lines changed

Some content is hidden

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

149 files changed

+23985
-76
lines changed

.main-meta/main.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
"content":{
55
"metaDataVersion":"1.3.0",
66
"name":"com.microchip.mplabx.project.dspic33e-code-examples",
7-
"version":"0.1.0",
8-
"displayName":"DSPIC33E Code Examples",
7+
"version":"1.0.0",
8+
"displayName":"dsPIC33E Code Examples",
99
"projectName":"dspic33e-code-examples",
10-
"shortDescription":"DSPIC33E Code Examples",
10+
"shortDescription":"dsPIC33E Code Examples",
1111
"ide":{
1212
"name":"MPLABX",
13-
"semverRange":">=5.50.0"
13+
"semverRange":">=6.00"
1414
},
1515
"compiler":{
1616
"name":"XC16",
17-
"semverRange":"^1.50.0"
17+
"semverRange":"^2.00"
1818
},
1919
"dfp":{
2020
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
@@ -26,7 +26,7 @@
2626
"content":{
2727
"metaDataVersion":"1.0.0",
2828
"category":"com.microchip.device",
29-
"name":"DSPIC33EP512GM710",
29+
"name":"dsPIC33EP512GM710",
3030
"versionRange":"*"
3131
}
3232
},

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
![image](images/microchip.jpg)
22

3-
## DSPIC33E CODE EXAMPLES
3+
## dsPIC33E CODE EXAMPLES
44

5-
This repository contains the code examples for DSPIC33E Device Families.
5+
This repository contains the code examples for dsPIC33E Device Families.
66

77

88

changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# DSPIC33E Code Examples v0.1.0
1+
# dsPIC33E Code Examples v0.1.0
22
### Release Highlights
33

4-
Initial Release of DSPIC33E code examples on GitHub.
4+
Initial Release of dsPIC33E code examples on GitHub.
55

66

77

dspic33e-adc-1msps/.main-meta/main.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"shortDescription":"ADC Sampling at 1.1MSPS",
1111
"ide":{
1212
"name":"MPLABX",
13-
"semverRange":">=5.50.0"
13+
"semverRange":">=6.00"
1414
},
1515
"compiler":{
1616
"name":"XC16",
17-
"semverRange":"^1.70.0"
17+
"semverRange":"^2.00"
1818
},
1919
"dfp":{
2020
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
@@ -26,7 +26,7 @@
2626
"content":{
2727
"metaDataVersion":"1.0.0",
2828
"category":"com.microchip.device",
29-
"name":"DSPIC33EP512GM710",
29+
"name":"dsPIC33EP512GM710",
3030
"versionRange":"*"
3131
}
3232
},

dspic33e-adc-1msps/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ In this example, ADC is set up to convert AIN0 using CH0 and CH1 sample/hold in
88
at 1.1MHz throughput rate. ADC clock is configured at 13.3Mhz or Tad=75ns
99
ADC Conversion Time for 10-bit conversion is Tc=12 * Tab = 900ns (1.1MHz).
1010

11-
void initAdc1(void);
11+
void initAdc1(void);
1212
ADC CH0 and CH1 S/H is set-up to covert AIN0 in 10-bit mode. ADC is configured to next sample data immediately after the conversion.
1313
So, ADC keeps conversion data through CH0/CH1 S/H alternatively. Effective conversion rate is 1.1Mhz
1414

15-
void initDma0(void);
15+
void initDma0(void);
1616
DMA channel 0 is configured in ping-pong mode to move the converted data from ADC to DMA RAM on every sample/convert sequence.
1717
It generates interrupt after every 16 sample transfer.
1818

19-
void \__attribute\__((\__interrupt\__)) _DMA0Interrupt(void);
19+
void \_\_attribute\_\_((\_\_interrupt\_\_)) _DMA0Interrupt(void);
2020
DMA interrupt service routine, moves the data from DMA buffer to ADC signal buffer and collects 256 samples.
2121

2222
The Toggle frequency of one pulse should be around 240us(micro second), if the operating clock frequency at 40Mhz.
@@ -31,6 +31,6 @@ Short AN0/AN1 with +3.3v to get analog signal for sampling. These values should
3131

3232
## Software Used
3333

34-
- MPLAB® X IDE v5.50 or newer (https://www.microchip.com/mplabx)
35-
- MPLAB® XC16 v1.70 or newer (https://www.microchip.com/xc)
34+
- MPLAB® X IDE v6.00 or newer (https://www.microchip.com/mplabx)
35+
- MPLAB® XC16 v2.00 or newer (https://www.microchip.com/xc)
3636

dspic33e-adc-fir-dma/.main-meta/main.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"shortDescription":"ADC Sampling and FIR Filtering",
1111
"ide":{
1212
"name":"MPLABX",
13-
"semverRange":">=5.50.0"
13+
"semverRange":">=6.00"
1414
},
1515
"compiler":{
1616
"name":"XC16",
17-
"semverRange":"^1.70.0"
17+
"semverRange":"^2.00"
1818
},
1919
"dfp":{
2020
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
@@ -26,7 +26,7 @@
2626
"content":{
2727
"metaDataVersion":"1.0.0",
2828
"category":"com.microchip.device",
29-
"name":"DSPIC33EP512GM710",
29+
"name":"dsPIC33EP512GM710",
3030
"versionRange":"*"
3131
}
3232
},

dspic33e-adc-fir-dma/README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,43 @@
44

55
## Description:
66

7-
In this example, ADC is configured to sample (AN5) at 250 KHz rate and the converted data is assembled in a 480-sample buffer. This input data is then filtered using the block FIR filter function from the DSP library. A 20-tap filter is used.
8-
Timer 3 is setup to time-out every 4 microseconds (250 KHz rate). On every Timer3 time-out (every Ts = 4 microsecs), the ADC module will stop sampling and trigger a 10-bit A/D conversion. At that time, the conversion process starts and completes Tc = 12 * Tad = 1.2 microsecs later.
9-
When the conversion is complete, the module starts sampling again.
10-
However, since Timer3 is already on and counting, about (Ts-Tc) secs later Timer3 will expire again and trigger the next conversion.
11-
The DMA is configured in continuous, ping pong mode, such that after the DMA channel has read 480 samples into a buffer (BufferA/BufferB) a DMA interrupt is generated.
12-
These samples are filtered by a function call in the main function while the DMA controller starts filling new ADC samples into buffer (BufferB/BufferA). Thus the two buffers are alternately filled and processed in an infinite loop.
13-
The ADC module clock time period is configured as Tad = Tcy * (ADCS+1) = (1/40M) * 1 = 100ns nanosecs with ADCS = 3. Hence the conversion time for 10-bit A/D is 12 * Tad = 1.2 microsecs.
14-
FIRStruct describes the data structure for FIR filter with the filter specifications given below. FIRStructInit() initializes the FIR filter structure parameters.
15-
FIRDelayInit() initializes the delay values in the FIR filter structure to zeros. The FIR() function applies an FIR filter to a sequence of source samples and places the result in a sequence of destination samples.
16-
17-
FIR filter specifications used:
18-
Sampling freq = 250 KHz
19-
FIR block size, N = 480
20-
Number of FIR coefficients, M = 20
21-
FCY = 40 MIPS
22-
Passband Frequency = 1300 Hz
23-
Stopband Frequency = 1350 Hz
24-
Passband Ripple = 1 dB
25-
Stopband Ripple = 3 dB
7+
In this example, ADC is configured to sample (AN5) at 250 KHz rate and the converted data is assembled in a 480-sample buffer. This input data is then filtered using the block FIR filter function from the DSP library. A 20-tap filter is used.
8+
Timer 3 is setup to time-out every 4 microseconds (250 KHz rate). On every Timer3 time-out (every Ts = 4 microsecs), the ADC module will stop sampling and trigger a 10-bit A/D conversion. At that time, the conversion process starts and completes Tc = 12 * Tad = 1.2 microsecs later.
9+
When the conversion is complete, the module starts sampling again.
10+
However, since Timer3 is already on and counting, about (Ts-Tc) secs later Timer3 will expire again and trigger the next conversion.
11+
The DMA is configured in continuous, ping pong mode, such that after the DMA channel has read 480 samples into a buffer (BufferA/BufferB) a DMA interrupt is generated.
12+
These samples are filtered by a function call in the main function while the DMA controller starts filling new ADC samples into buffer (BufferB/BufferA). Thus the two buffers are alternately filled and processed in an infinite loop.
13+
The ADC module clock time period is configured as Tad = Tcy * (ADCS+1) = (1/40M) * 1 = 100ns nanosecs with ADCS = 3. Hence the conversion time for 10-bit A/D is 12 * Tad = 1.2 microsecs.
14+
FIRStruct describes the data structure for FIR filter with the filter specifications given below. FIRStructInit() initializes the FIR filter structure parameters.
15+
FIRDelayInit() initializes the delay values in the FIR filter structure to zeros. The FIR() function applies an FIR filter to a sequence of source samples and places the result in a sequence of destination samples.
16+
17+
FIR filter specifications used:
18+
Sampling freq = 250 KHz
19+
FIR block size, N = 480
20+
Number of FIR coefficients, M = 20
21+
FCY = 40 MIPS
22+
Passband Frequency = 1300 Hz
23+
Stopband Frequency = 1350 Hz
24+
Passband Ripple = 1 dB
25+
Stopband Ripple = 3 dB
2626
Kaiser Windowing
2727

2828
The FIR() function takes [53+N(4+M)] instruction cycles. In this example, since N = 480 and M = 20, the total number of instruction cycles taken by FIR() is C = 11,573. Since the instruction cycle frequency is FCY = 40 MIPS the total time taken by the FIR filter to filter 480 samples is TFIR = C/FCY = 0.3 millisecs.
2929

3030
NOTE: A NOP associated with Y memory errata was removed from the fir.s source in the DSP library before using it in this code example, as this errata item only applies to certain dsPIC30F devices and does not affect the dsPIC33E device family.
3131

3232

33-
void initTmr3();
33+
void initTmr3();
3434
Timer 3 is configured to time-out at 250 KHz rate.
3535

36-
void initAdc1(void);
36+
void initAdc1(void);
3737
ADC module is set-up to convert AIN5 input using CH0 S/H on Timer 3 event in 10-bit mode.
3838

39-
void initDma0(void);
39+
void initDma0(void);
4040
DMA channel 0 is confiured in ping-pong mode to move the converted data from ADC to DMA RAM on every sample/convert sequence.
4141
It generates interrupt after every 480 sample transfer.
4242

43-
void \__attribute\__((\__interrupt\__)) _DMA0Interrupt(void);
43+
void \_\_attribute\_\_((\_\_interrupt\_\_)) _DMA0Interrupt(void);
4444
DMA interrupt service routine sets flag for FIR filtering on the data buffer.
4545

4646

@@ -52,6 +52,6 @@ DMA interrupt service routine sets flag for FIR filtering on the data buffer.
5252

5353
## Software Used
5454

55-
- MPLAB® X IDE v5.50 or newer (https://www.microchip.com/mplabx)
56-
- MPLAB® XC16 v1.70 or newer (https://www.microchip.com/xc)
55+
- MPLAB® X IDE v6.00 or newer (https://www.microchip.com/mplabx)
56+
- MPLAB® XC16 v2.00 or newer (https://www.microchip.com/xc)
5757

dspic33e-adc-iir-filter/.main-meta/main.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"shortDescription":"ADC Sampling and IIR Filtering",
1111
"ide":{
1212
"name":"MPLABX",
13-
"semverRange":">=5.50.0"
13+
"semverRange":">=6.0"
1414
},
1515
"compiler":{
1616
"name":"XC16",
17-
"semverRange":"^1.70.0"
17+
"semverRange":"^2.0"
1818
},
1919
"dfp":{
2020
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
@@ -26,7 +26,7 @@
2626
"content":{
2727
"metaDataVersion":"1.0.0",
2828
"category":"com.microchip.device",
29-
"name":"DSPIC33EP512GM710",
29+
"name":"dsPIC33EP512GM710",
3030
"versionRange":"*"
3131
}
3232
},

dspic33e-adc-iir-filter/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66

77
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.
88

9-
Timer 3 is setup to time-out every 125 microseconds (8Khz Rate).
10-
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.
11-
At that time, the conversion process starts and completes Tc=14*Tad periods later.
9+
Timer 3 is setup to time-out every 125 microseconds (8Khz Rate).
10+
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.
11+
At that time, the conversion process starts and completes Tc=14*Tad periods later.
1212
When the conversion completes, the module starts sampling again. However, since Timer3
1313
is already on and counting, about (Ts-Tc)us later, Timer3 will expire again and trigger
1414
next conversion.
1515

1616
ADC module clock time period is configured as Tad=Tcy*(ADCS+1)= (1/40M)*64 = 1.6us (625Khz).
1717
Hence the conversion time for 12-bit A/D Conversion Time Tc=14*Tad = 22.4us
1818

19-
void initTmr3();
19+
void initTmr3();
2020
Timer 3 is configured to time-out at 8Khz rate.
2121

22-
void initAdc1(void);
22+
void initAdc1(void);
2323
ADC module is set-up to convert AIN5 input using CH0 S/H on Timer 3 event in 12-bit mode.
2424

25-
void initDma0(void);
25+
void initDma0(void);
2626
DMA channel 0 is configured in ping-pong mode to move the converted data from ADC to DMA RAM on every sample/convert sequence.
2727
It generates interrupt after every 256 sample transfer.
2828

29-
void \__attribute\__((\__interrupt\__)) _DMA0Interrupt(void);
29+
void \_\_attribute\_\_((\_\_interrupt\_\_)) _DMA0Interrupt(void);
3030
DMA interrupt service routine performs IIR filtering on the data buffer.
3131

3232

@@ -38,5 +38,5 @@ DMA interrupt service routine performs IIR filtering on the data buffer.
3838

3939
## Software Used
4040

41-
- MPLAB® X IDE v5.50 or newer (https://www.microchip.com/mplabx)
42-
- MPLAB® XC16 v1.70 or newer (https://www.microchip.com/xc)
41+
- MPLAB® X IDE v6.00 or newer (https://www.microchip.com/mplabx)
42+
- MPLAB® XC16 v2.00 or newer (https://www.microchip.com/xc)

dspic33e-atan2/.main-meta/main.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"shortDescription":"atan2 Function",
1111
"ide":{
1212
"name":"MPLABX",
13-
"semverRange":">=5.50.0"
13+
"semverRange":">=6.0"
1414
},
1515
"compiler":{
1616
"name":"XC16",
17-
"semverRange":"^1.70.0"
17+
"semverRange":"^2.0"
1818
},
1919
"dfp":{
2020
"name":"dsPIC33E-GM-GP-MC-GU-MU_DFP",
@@ -26,7 +26,7 @@
2626
"content":{
2727
"metaDataVersion":"1.0.0",
2828
"category":"com.microchip.device",
29-
"name":"DSPIC33EP512GM710",
29+
"name":"dsPIC33EP512GM710",
3030
"versionRange":"*"
3131
}
3232
},

0 commit comments

Comments
 (0)