Skip to content

Commit 35df845

Browse files
committed
Merge pull request #7 in MCU16CE/dspic33ck-power-pwm-phase-shift from develop to master
* commit '7305e2fd652c70a5c5764f46de07533976c00b9b': (26 commits) use XC16 v1.5 building the code change the compiler version from 1.6 to 1.5, rename the driver folder to common, update main.c code descriptopm Updated changes in data structure declarations in SFR abstraction driver into PWM object handlers in main() Incorporated change in data structure declarations in SFR abstraction driver into PWM initialization example Changed PWM configuration code example enumeration once more. Now Code example enumerations are called 'Lab 1', 'Lab 2'. 'Lab 3', etc. REplaced PWM SFR abstraction driver with latest version. major change was simplification of data structure to make the driver compliant with other SFR abstraction drivers and make usage more intuitive Fixed software version labels to start with MPLABX(R) Changed roman enumeration of code example to arabic numbers try another readme edit try another readme edit edit readme.md file another edit for README.md fie edited changelog.md and README.md file moved the device_setup.mc3 file to MPLABX root folder deleted changelog.txt file use main.jason based on MCU16CE project change ma330048_R30_pinmap.h to ma330048_r30_pinmap.h in hal.h file update the .citd with the original file from MCU16 CE update configuration.xml, and project xml ovewrite the previous Jenkinsfilek8s ...
2 parents 8863fb7 + 7305e2f commit 35df845

Some content is hidden

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

45 files changed

+27243
-26
lines changed

.gitignore

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# .gitignore file
2+
#
3+
# Set up for Microchip/MPLAB X development
4+
#
5+
# Default gitignore files for code examples, only removing/ignoring usual MPLAB X clutter
6+
7+
# Object files
8+
*.o
9+
*.ko
10+
*.obj
11+
*.elf
12+
13+
# Executables
14+
*.exe
15+
16+
# Netbeans specific
17+
~*.*
18+
nbproject/build/
19+
nbproject/dist/
20+
nbproject/private/
21+
nbproject/disassembly/
22+
build/
23+
dist/
24+
private/
25+
disassembly/
26+
*.zip
27+
*.mk
28+
*.bash
29+
Makefile-genesis.properties
30+
31+
# MPLAB X Trace specific
32+
*.log
33+
*.inx
34+
35+
# KDE specific
36+
.directory
37+
38+
# Misc
39+
.svn
40+
*.bak
41+
*.doc
42+
*.docx
43+
44+
45+

.main-meta/main.json

+14-9
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"content":{
55
"metaDataVersion":"1.0.0",
66
"name":"com.microchip.mplabx.project.dspic33ck-power-pwm-phase-shift",
7-
"version":"x.x.x",
8-
"displayName":"xxxxxxxxxxxxxxx",
7+
"version":"1.0.0",
8+
"displayName":"dsPIC33CK/CH-MP PWM Configuration: Phase Shifted PWM Output",
99
"projectName":"dspic33ck-power-pwm-phase-shift",
10-
"shortDescription":"xxxxxxxxxxxxxxx",
10+
"shortDescription":"Phase Shifted PWM Output Configuration Example for dsPIC33CK-MP devices",
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":"dsPIC33CK-MP_DFP",
21+
"semverRange":"^1.4.102"
2222
},
2323
"configurator": {
2424
"name": "MCC",
@@ -30,17 +30,22 @@
3030
"content":{
3131
"metaDataVersion":"1.0.0",
3232
"category":"com.microchip.device",
33-
"name":"xxxxxxxxxxxxxxx",
33+
"name":"dsPIC33CK",
3434
"versionRange":"*"
3535
}
3636
},
3737
"peripherals":[
3838
"GPIO",
39-
"UART"
39+
"PWM",
40+
"Timer"
4041
],
4142
"keywords":[
42-
"GPIO",
43-
"UART"
43+
"dsc",
44+
"dspic",
45+
"power",
46+
"power-conversion",
47+
"power-supply",
48+
"smps"
4449
]
4550
}
4651
}

LICENSE.txt

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
© [2020] Microchip Technology Inc. and its subsidiaries
2-
3-
Subject to your compliance with these terms, you may use this Microchip software and any derivatives exclusively with Microchip products. You are responsible
4-
for complying with third party license terms applicable to your use of third party software (including open source software) that may accompany this Microchip
5-
software. SOFTWARE IS “AS IS.” NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
6-
MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS,
7-
DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
8-
FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP’S TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT EXCEED AMOUNT OF FEES, IF ANY, YOU
9-
PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
1+
(c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this
2+
software and any derivatives exclusively with Microchip products.
3+
4+
5+
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
6+
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
7+
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
8+
PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
9+
WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
10+
11+
12+
13+
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
14+
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
15+
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
16+
BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
17+
FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
18+
ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
19+
THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
20+
21+
22+
23+
MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
24+
TERMS.
25+

README.md

+79-4
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,100 @@
1-
![image](images/microchip.jpg)
1+
<div id="readme" class="Box-body readme blob js-code-block-container">
2+
<article class="markdown-body entry-content p-3 p-md-6" itemprop="This needs to be locked down and 'never' changed">
3+
<p><a target="_blank" href="https://www.microchip.com" rel="nofollow"><img src="images/microchip.png" alt="MCHP" width="200";"></a></p>
24

3-
## DSPIC33CK POWER PWM PHASE SHIFT
5+
# dsPIC33C High-Resolution PWM Configuration: Lab 4
6+
**Phase-Shifted PWM Waveform Generation**
47

5-
Board Image if any.
8+
<p><center><a href="https://www.microchip.com/MA330048" rel="nofollow">
9+
<img src="images/ma330048.jpg" alt="dsPIC33CK Digital Power Plug-In Module" width="300"></a></center></p>
10+
11+
- - -
612

713
## Summary
14+
Learning how to use the High Resolution PWM Module of dsPIC33C MP devices, Lab 4:
15+
Code example for dsPIC33CK and dsPIC33CH devices showing a basic configuration of the high-resolution PWM module using two PWM generator channels generating a Phase-Shifted PWM waveforms
816

17+
- - -
918

1019
## Related Documentation
20+
- [dsPIC33CK256MP508 Family Data Sheet](https://ww1.microchip.com/downloads/en/DeviceDoc/dsPIC33CK256MP508-Family-Data-Sheet-DS70005349G.pdf)
21+
- [dsPIC33CK256MP508 Family Silicon Errata and Data Sheet Clarification](https://ww1.microchip.com/downloads/en/DeviceDoc/dsPIC33CK256MP508-Family-Silicon-Errata-and-Data-Sheet-Clarification-DS80000796G.pdf)
22+
- [dsPIC33CH512MP508 Family Data Sheet](http://ww1.microchip.com/downloads/en/DeviceDoc/dsPIC33CH512MP508-Family-Data-Sheet-DS70005371D.pdf)
23+
- [dsPIC33CH512MP508 Family Silicon Errata and Data Sheet Clarification](http://ww1.microchip.com/downloads/en/DeviceDoc/dsPIC33CH512MP508-Family-Silicon-Errata-and-Data-Sheet-Clarification-DS80000805F.pdf)
1124

25+
**Please always check for the latest data sheets on the respective product websites:**
26+
- [dsPIC33CK256MP508 Family](https://www.microchip.com/dsPIC33CK256MP508)
27+
- [dsPIC33CH512MP508 Family](https://www.microchip.com/dsPIC33CH512MP508)
1228

1329
## Software Used
14-
30+
- [MPLAB® X IDE v5.40](https://www.microchip.com/mplabx-ide-windows-installer)
31+
- [MPLAB® XC16 Compiler v1.50](https://www.microchip.com/mplabxc16windows)
32+
- [MPLAB® Code Configurator v4.01](https://www.microchip.com/mplab/mplab-code-configurator)
1533

1634
## Hardware Used
35+
- Digital Power Development Board, Part-No. [DM330029](https://www.microchip.com/DM330029)
36+
- dsPIC33CK Digital Power Plug-In Module (DP PIM), Part-No. [MA330048](https://www.microchip.com/MA330048)
37+
- Alternatively: dsPIC33CH Digital Power Plug-In Module (DP PIM), Part-No. [MA330049](https://www.microchip.com/MA330049)
38+
39+
## Supported Target Devices
40+
- [dsPIC33CK256MP506](https://www.microchip.com/dsPIC33CK256MP506)
41+
- [dsPIC33CH512MP506](https://www.microchip.com/dsPIC33CH512MP506)
42+
- Code compatible with all Single and Dual Core dsPIC33C MP families of devices
1743

44+
- - -
1845

1946
## Setup
47+
- Plug-In the dsPIC33CK or dsPIC33CH Digital Power Plug In Module into the Digital Power Development Board PIM socket J1
48+
- Open and compile the firmware and program the DSC
2049

50+
<br><center><img src="images/dm330029.jpg" width="400"></center><br>
2151

2252
## Operation
53+
After the device has been programmed and the MCU starts up, a 90 degrees phase shift between the two synchronized PWM Generators is generated see below screen capture. Both PWM Generator #1 and #3 are configured in complementary mode with 200 kHz frequency and 50% duty cycle waveform outputs. PWM Generator 1 output is available at PWM1H/L pins while PWM Generator 3 output is available at PWM3H/L pins.
54+
55+
<br><center><img src="images/pwm90phaseshift.png" width="400"></center><br>
56+
<br><center>*CH1(blue):PWM1H CH2(green):PWM1L CH3(red):PWM3H CH4(purple):PWM3L*</center><br>
57+
58+
By pressing the on-board push button *USER* on the Digital Power Development Board, the phase shift is toggled between the initial 90 degrees and 180 degrees see below screen capture.
59+
60+
<br><center><img src="images/pwm180phaseshift.png" width="400"></center><br>
61+
<br><center>*CH1(blue):PWM1H CH2(green):PWM1L CH3(red):PWM3H CH4(purple):PWM3L*</center><br>
62+
63+
64+
Please refer to section *FIRMWARE QUICK-START GUIDE* below for more information on the initialization process and code structure.
65+
66+
<br><center><img src="images/dm330029-pinmap.png" width="600"></center><br>
67+
68+
- - -
69+
70+
## FIRMWARE QUICK-START GUIDE
71+
72+
This code example builds on previous code examples showing how to use Microchip Code Configurator (MCC) to set up device clock domains.
73+
Although MCC also supports configuration tools for the High Resolution PWM module, PWM configuration in this example builds on generic peripheral drivers to help users better understand the peripheral architecture and key aspects of specific configurations and operating modes.
74+
In each PWM example code project the PWM configuration procedure is located in the user file pwm.c, where each register bit required to achieve/enable the specific function or mode of interest is set and its function described with comments.
75+
Once users are familiar with the architecture, features and capabilities, both configuration options (generic peripheral library or MCC) may be used.
76+
77+
#### a) Project Directory Structure <br/>
78+
The project contains four sub-directories
79+
1. config: location of all hardware abstraction header files
80+
2. common: location of generic peripheral drivers
81+
3. MCC Generated Files: all device configuration files auto-generated by MCC
82+
4. root: application user code
83+
84+
On the hard drive, main.c/h are located in the MPLAB X project directory.
85+
All other user files, incl. peripheral drivers, are located in the sub-directory *sources*.
86+
Files generated by MCC are always located in their own sub-directory *mcc_generated-files*
87+
88+
#### b) Using the generic PWM peripheral driver <br/>
89+
The PWM peripheral driver files p33c_pwm.c/h provide data structures representing the Special Function Register (SFR) sets of PWM generators and the PWM base module. These 'virtual' PWM objects are used to load, read and modify PWM generator configurations without the need for hard-coded instructions, which would make the code hard to migrate from one peripheral to another or even across devices.To simplify PWM configurations, in these examples, each register is reset to a known default state before the user configuration of interest is set. Thus, only the register setting which really matters for a certain features/function are shown.
90+
91+
To learn more about the generic PWM driver, its supported features and intended use cases, please read the comments inside p33c_pwm.c.
92+
93+
#### c) Executing the Code Example <br/>
94+
This code has been written to automatically start up and perform the function of interest. Please read the demo instructions on top of file main.c to learn more about the code example, test points, expected signals and demo mode operation.
95+
2396

2497

98+
- - -
2599

100+
© 2020, Microchip Technology Inc.

changelog.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# Project Name or repo name release version
2-
### Release Highlights
3-
1+
# dspic33ck-power-pwm-phase-shift, release v1.0.0
42

3+
### Release Highlights
4+
This is the initial release demonstrating the basic configuration of a high-resolution PWM generator of the dsPIC33C family of devices.
5+
This example is part of a series of code examples highlighting specific operating modes and features.
56

67
### Features Added\Updated
7-
8+
In this intial version the on-board LED of the dsPIC33CK Digital Power Plug-In Module is toggled with a interval üperiod of 300 ms, when the controller is running at maximum speed of 100 MIPS.
9+
After startup, 90 degrees phase shift will be generated between pwm generator #1 and pwm generator #3. By pressing the on-board push button *USER* on the Digital Power Develpoment Board, the phase shift is toggled between the initial 90 degrees and 180 degrees.
810

911

+113
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)