Note the following details of the code protection feature on Microchip devices:
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•Microchip is willing to work with the customer who is concerned about the integrity of their code.
•Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
SEEVAL, SmartSensor and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, ECAN,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, Linear Active
Thermistor, Mindi, MiWi, MPASM, MPLIB, MPLINK, PICkit,
PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartTel, Total
Endurance, UNI/O, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
Microchip received ISO/TS-16949:2002 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona, Gresham, Oregon and Mountain View, California. The
Company’s quality system processes and procedures are for its PIC
8-bit MCUs, KEELOQ
microperipherals, no nvolatile memory and analog products. In addition,
Microchip’s quality system for the design and manufacture of
development systems is ISO 9001:2000 certified.
All documentation becomes dated, and this manual is no exception. Microchip tools and
documentation are constantly evolving to meet customer needs, so some actual dialogs
and/or tool descriptions may differ from those in this document. Please refer to our web site
(www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each
page, in front of the page number. The numbering convention for the DS number is
“DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the
document.
For the most up-to-date information on development tools, see the MPLAB
Select the Help menu, and then Topics to open a list of available on-line help files.
®
IDE on-line help.
This document contains general information that is useful to know before using the
dsPICDEM™ SMPS Buck Development Board.
Items discussed in this preface include:
• About this Guide
• Conventions Used in this Guide
• Warranty Registration
• Recommended Reading
• The Microchip Web Site
• Development Systems Customer Change Notification Service
• Customer Support
• Document Revision History
ABOUT THIS GUIDE
This document describes how to use the dsPICDEM™ SMPS Buck Development
Board development tool. The manual layout is as follows:
• Chapter 1. “Introduction” – This chapter introduces the dsPICDEM™ SMPS
Buck Development Board and provides a brief descriptions of the hardware.
• Chapter 2. “Hardware Overview” – This chapter describes the dsPICDEM™
SMPS Buck Development Board hardware.
• Chapter 3. “Using the dsPIC30F2020 Device” – This chapter goes through a
basic step by step process for getting your dsPICDEM™ SMPS Buck Development Board up and running with the MPLAB
a dsPIC30F2020 device.
• Chapter 4. “Demonstration Program Operation” – This chapter describes the
operation of the dsPICDEM™ SMPS Buck Development Board.
• Appendix A. “Schematic and Layouts” – This section illustrates the
dsPICDEM™ SMPS Buck Development Board layout and provides hardware
schematic diagrams.
Please complete the enclosed Warranty Registration Card and mail it promptly.
Sending in the Warranty Registration Card entitles users to receive new product
updates. Interim software releases are available at the Microchip web site.
RECOMMENDED READING
This user's guide describes how to use the dsPICDEM™ SMPS Buck Development
Board. Other useful documents are listed below. The following Microchip documents
are available and recommended as supplemental reference resources.
Readme Files
For the latest information on using other tools, read the tool-specific Readme files in
the Readmes subdirectory of the MPLAB IDE installation directory. The Readme files
contain update information and known issues that may not be included in this user’s
guide.
THE MICROCHIP WEB SITE
Microchip provides online support via our web site at www.microchip.com. This web
site is used as a means to make files and information easily available to customers.
Accessible by using your favorite Internet browser, the web site contains the following
information:
• Product Support – Data sheets and errata, application notes and sample
programs, design resources, user’s guides and hardware support documents,
latest software releases and archived software
• General Technical Support – Frequently Asked Questions (FAQs), technical
support requests, online discussion groups, Microchip consultant program
member listing
• Business of Microchip – Product selector and ordering guides, latest Microchip
press releases, listing of seminars and events, listings of Microchip sales offices,
distributors and factory representatives
DEVELOPMENT SYSTEMS CUSTOMER CHANGE NOTIFICATION SERVICE
Microchip’s customer notification service helps keep customers current on Microchip
products. Subscribers will receive e-mail notification whenever there are changes,
updates, revisions or errata related to a specified product family or development tool of
interest.
To register, access the Microchip web site at www.microchip.com, click on Customer
Change Notification and follow the registration instructions.
The Development Systems product group categories are:
• Compilers – The latest information on Microchip C compilers and other language
tools. These include the MPLAB C18 and MPLAB C30 C compilers; MPASM™
and MPLAB ASM30 assemblers; MPLINK™ and MPLAB LINK30 object linkers;
and MPLIB™ and MPLAB LIB30 object librarians.
• Emulators – The latest information on Microchip in-circuit emulators.This
includes the MPLAB ICE 2000 and MPLAB ICE 4000.
• In-Circuit Debuggers – The latest information on the Microchip in-circuit
debugger, MPLAB ICD 2.
• MPLAB
Integrated Development Environment for development systems tools. This list is
focused on the MPLAB IDE, MPLAB SIM simulator, MPLAB IDE Project Manager
and general editing and debugging features.
• Programmers – The latest information on Microchip programmers. These include
the MPLAB PM3 and PRO MATE
Plus and PICkit
®
IDE – The latest information on Microchip MPLAB IDE, the Windows®
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Field Application Engineer (FAE)
• Technical Support
Customers should contact their distributor, representative or field application engineer
(FAE) for support. Local sales offices are also available to help customers. A listing of
sales offices and locations is included in the back of this document.
Technical support is available through the web site at: http://support.microchip.com
Modern power supplies are becoming smaller, more efficient, more flexible and less
costly. These desirable enhancements have come about as digital signal controllers
have been incorporated into Switched Mode Power Supply (SMPS) designs. Buck
converters are used when the desired output voltage is smaller than the input voltage.
This chapter introduces and provides an overview of the dsPICDEM™ SMPS Buck
Development Board. Topics covered include:
•Overview
• dsPICDEM™ SMPS Buck Development Board Kit
• dsPICDEM™ SMPS Buck Development Board Features
1.1OVERVIEW
Figure 1-1 is a block diagram of the dsPICDEM™ SMPS Buck Development Board, A
dsPIC30F2020 DSC controls two independent DC/DC synchronous buck converters,
providing closed-loop Proportional, Integral, Derivative (PID) control in software to
maintain desired output voltage levels. The dsPIC
sary memory and peripherals for A/D conversion, PWM generation and general
purpose I/O, precluding the need to perform these functions in external circuitry.
dsPIC DSC SMPS devices are specifically designed to provide low-cost, efficient control of a wide range of power supply topologies. Their specialized peripherals facilitate
closed-loop feedback control of switched mode power supplies while also providing
communications for remote monitoring and supervisory control.
The dsPICDEM™ SMPS Buck Development Board aids in rapid development of multiple buck converters using dsPIC30F1010/2020 Digital Signal Controllers. The
dsPIC30F1010/2020 devices offer these features and capabilities:
• Integrated program and data memory on a single chip
• Ultra fast interrupt response time and hardware interrupt priority logic
• 2000 ksps, on-chip ADC with four dedicated sample/hold circuits for multiple loop
control
• Four independent, high-resolution PWM generators specially designed to support
different power topology
• Four analog comparators for system protection
• On-chip system communications (I
• On-chip RC oscillator for lower system cost
• High-current sink/source I/O pins: 25 mA/25mA
• 30 MIPS performance CPU
1.2dsPICDEM™ SMPS BUCK DEVELOPMENT BOARD KIT
2
C/SPI/UART)
The dsPICDEM™ SMPS Buck Development Board kit contains these items:
• dsPICDEM™ SMPS Buck Development Board
• dsPICDEM™ SMPS Buck Development Board CD containing example code and
relevant documentation
1.3dsPICDEM™ SMPS BUCK DEVELOPMENT BOARD FEATURES
The dsPICDEM™ SMPS Buck Development Board incorporates these features:
1.3.1Power Stages
• Two synchronous buck converter power stages
• Voltage/current measurement for digital control of buck converters
• In-rush current limiting
• Switchable 5Ω/5W resistive load on VOUT1
• Buck Converter 1 output (VOUT1) on J1 connector for external loading
• Buck Converter 2 output (VOUT2) on J2 connector for external loading
The dsPICDEM™ SMPS Buck Development Board obtains +9V power from a power
connector for a +9V AC/DC wall adapter as well as auxiliary power connection points
(AUX PWR IN). A separate +5V DC regulator provides the operating voltage (V
required by the dsPIC30F2020 device.
2.1.2ICD Connector
An RJ11 female connector (J5) connects the MPLAB® ICD 2 to the dsPIC30F2020
device for programming and debugging.
2.1.3RS-232 Serial Port
An RS-232 serial communication port (J6) is provided for monitoring and controlling the
power supply by a remote processor. The PGM DEBUGswitch (SW2) must be in set
in program mode position (PGM) to communicate via the UART.
2.1.4VOUT1
An external load can be connected to VOUT1 through connector J1. An on-board 5Ω
5 watt resistor is connected at the output of VOUT1 through MOSFET U6 to optionally
load the first buck converter circuit. This load can be enabled or disabled in software.
See Figure A-3: “dsPICDEM™ SMPS Buck Development Board Schematic 2 of 3”
DD)
2.1.5VOUT2
An external load can be connected to VOUT2 through connector J1.See Figure
A-4: “dsPICDEM™ SMPS Buck Development Board Schematic 3 of 3”
2.1.6Expansion Header
Header J7 is an expansion connector that matches the dsPIC30F2020 device pins (see
Table 2-2 for pin usage information).
Figure 2-2 identifies the hardware elements that comprise the user interface (jumpers,
switches, LEDs and potentiometers) on the dsPICDEM™ SMPS Buck Development
Board.
FIGURE 2-2:JUMPERS/LED/SWITCHES/POTENTIOMETER
Jumpers
MCLR Reset Switch
S3
JP1JP3JP4 JP2 JP5J4J8
LED1 LED3R29R30R35
Potentiometers
S2S4
SwitchesLEDs
2.2.1Jumpers
The dsPICDEM™ SMPS Buck Development Board has seven jumpers that determine
how features on the buck converters are used. Table 2-3 lists these jumpers and their
functions.
TABLE 2-3:JUMPER DESCRIPTIONS
JumperDescription
JP1Buck Converter 1 Input Select
ON: Connects the Input power to buck converter 1
OFF: Input to buck converter 1 is left open
JP2Buck Converter 1 Load Drive
ON: Turn ON buck converter 1 load (5
OFF: On board load is disabled
JP3Buck Converter 2 Input Select
ON: Connects the Input power to buck converter 2
OFF: Input to buck converter 2 is left open
ON: Enable Synchronous MOSFET drive for buck converter 1
OFF: Disable Synchronous MOSFET drive for buck converter 1
JP5Buck Converter 2 Synchronous MOSFET Drive
ON: Enable Synchronous MOSFET drive for buck converter 2
OFF: Disable Synchronous MOSFET drive for buck converter 2
J4Buck Converter 1 Current Sense Position Select
Jumper J4 is connected to the buck converter 1 output bulk capacitor. It allows the
user to select the current sense resistor position for different applications.
PositionFunction
1-2Current sense resistor senses output load of converter 1
2-3Current sense resistor senses inductor current of converter 1
J8Buck Converter 2 Current Sense Position Select
Jumper J8 is connected to the buck converter 2 output bulk capacitor. It allows the
user to select the current sense resistor position for different applications.
PositionFunction
1-2Current sense resistor senses load current of converter 2
2-3Current sense resistor senses inductor current of converter 2
2.2.2Switches, LEDs and Potentiometers
The dsPICDEM™ SMPS Buck Development Board has 2 switches, 3 potentiometers
and one LED for user applications. The board also has one power ON status LED and
device reset switch.
TABLE 2-4:PUSH BUTTONS, POTENTIOMETERS AND LEDS
LabelHardware Elements
S2, S4Push button switches connected to port pins RE5 and RE4, respectively, for user
applications. When momentarily depressed, the switch connects the respective
port pin to ground (Logical ‘0’).
R29, R30,
R35
LED3User programmable LED; programmed by writing to port pin RE9.
LED1Power-on status LED; indicates status of 5V regulator.
S3Reset switch. When momentarily depressed, the switch asserts the MCLR
User potentiometers connected to analog input pins (AN5, AN6 and AN7),
respectively, for user applications.
®
to the dsPIC
DSC device for Reset.
signal
2.2.3Test Points
The dsPICDEM™ SMPS Buck Development Board provides seven power test points
that can be used to debug the power stage and eight PWM test points that can be used
to check the PWM signal and gate drive to buck converter 1 and 2. These test points
are described in Table 2-5 and Table 2-6, respectively.
The dsPIC30F2020 device program pins (PGC/PGD) are multiplexed with the UART
pins (U1RX and U1TX). A DIP switch (SW2) selects whether the default programming
pin pair (PGC/PGC) are used to program the device. Because PGC and PGD are
multiplexed with the UART pins, the pins can only be used to program the device.
Debugging is not possible with PGC/EMUC and PGD/EMUD.
When SW2 is in the PGM position, the PGC/PGD and PGC1/PGD1 pins are connected
to the ICD 2. This configuration allows you to program the device with either the default
programming pin pair (PGC/PGD) or the first set of auxiliary programming pins
(PGC1/PGD1). Emulation and debugging in not possible when SW2 is in the PGM
position and the default programming/emulation pins are selected (via the
Configuration bits).
When SW2 is in the DEBUG position, PGC1/EMUC1 and PGD1/EMUD1 must be
selected as the debugging pin pair in the Configuration bit settings window. Both
programming and debugging are possible in this configuration.
This chapter is a self-paced tutorial to get you started using the dsPICDEM™ SMPS
Buck Development Board with its on-board dsPIC30F2020 device. Information is provided on these topics:
• Tutorial Overview
• Creating the Project
• Building the Code
• Programming the Chip
• Debugging the Code
3.1TUTORIAL OVERVIEW
The tutorial demonstrates the main features of MPLAB IDE Integrated Development
Environment and the MPLAB ICD 2 In-Circuit Debugger as they are used with the
dsPICDEM™ SMPS Buck Development Board. On completing this tutorial, you should
be able to:
• Create a project using the Project Wizard.
• Assemble and link the code and set the Configuration bits.
• Set up MPLAB IDE to use the MPLAB ICD 2 In-Circuit Debugger.
• Program the chip with the MPLAB ICD 2.
• View the code execution.
• View registers in a Watch window.
• Set a breakpoint and make the code halt at a chosen location.
• Use the function keys to Reset, Run, Halt and Single Step the code.
Before you begin the tutorial, run the install program on the dsPICDEM™ SMPS Buck
Development Board CD. The default installation location is:
The first step is to create a project and workspace in MPLAB IDE. Usually, you will have
one project in one workspace.
Note:These instructions presume the use of MPLAB IDE 7.43 or newer.
A project contains the files needed to build an application (source code, linker script
files, etc.) along with their associations to various build tools and build options.
A workspace contains one or more projects and information on the selected device,
debug tool and/or programmer, open windows and their location, and other IDE
configuration settings. MPLAB IDE provides a Project Wizard to help create new
projects.
After the project wizard completes, the MPLAB IDE project window shows the
isr_traps.s and SMPS_PID_Control.s files in the Source Files folder, the
p30f2020.inc file in the Header Files folder and the p30f2020.gld file in the Linker
A project and workspace has now been created in MPLAB IDE. DualBuck.mcw is the
workspace file and DualBuck.mcp is the project file. Double click the
SMPS_PID_Controls.s file in the project window to open the file. MPLAB IDE should
now look similar to Figure 3-7.
In this project, building the code consists of assembling the SMPS_PID_Controls.s
and isr_traps.s files to create their respective object files,
and isr_traps.o, and then linking the object files to create the DualBuck.hex and
DualBuck.cof output files. The .hex file contains the data necessary to program the
device and the .cof file contains additional information that lets you debug at the
source code level.
Before building, there are settings required to tell MPLAB IDE where to find the include
files and to reserve space for the extra debug code when the MPLAB ICD 2 is used.
The following line is near the top of the SMPS_PID_Controls.s file:
.include "p30f2020.inc"
This line causes a standard include file to be used. Microchip provides these files with
all the Special Function Register (SFR) labels already defined for convenience. To build
the code, select Build Options>Project
displays, as shown in Figure 3-8.
This path tells MPLAB IDE where to find the include files
•Click Apply and then click OK.
Note:The p30f2020.inc file was included when you added files to the project
folder (section Section 3.2.4 “Add Files to Project”). Selecting an
Assembler Include Path in the manner described here allows you to link to
the latest .inc file included with MPLAB IDE. Skip this step to use the
.inc file in the project folder.
3.3.2Link for ICD 2
It is necessary to tell the linker that the code should be built with the intention to debug.
This sets aside RAM for the MPLAB ICD 2 to use during debugging. If this step is not
done, the MPLAB ICD 2 will not function properly in Debug mode.
• On the Project Manager toolbar, select “Debug” from the drop-down box (see
Figure 3-9)
• From the Debugger menu, click Select Tool>MPLAB ICD 2 to designate the
MPLAB ICD 2 as the debug tool in MPLAB IDE.
•Select Debugger>Connect to connect the debugger to the device. The MPLAB
ICD 2 should report that it found the dsPIC30F2020 device, as shown in
Figure 3-13.
•Select Debugger>Settings
• Select the Program tab.
•Check Allow ICD 2 to select memories and ranges, as shown in Figure 3-14.
This setting will speed up operations by programming only a small part of the total
program memory.
Note:The MPLAB ICD 2 may need to download the new firmware if this is the first
time the MPLAB ICD 2 is being used with a dsPIC30F device. If any errors
are shown, double click the error message to get more information.
The MPLAB ICD 2 In-Circuit Debugger can be used to run, halt and step the code. A
breakpoint can be set to halt the program after the code has executed the instruction
at the breakpoint. The contents of the RAM and registers can be viewed whenever the
processor has been halted.
The MPLAB ICD 2 In-Circuit Debugger uses the following function keys to access the
main debugging functions:
<F5> Halt
<F6> Reset
<F7> Single Step
<F9> Run
In addition, there are more functions available by right clicking on a line of source code.
The most important of these are “Set Breakpoint” and “Run to Cursor”.
3.5.1Display the Code
• From the View menu, select View>Program Memory.
• On the Program Memory window, select the Symbolic tab, as shown in
Figure 3-16.
• Press <F5> to halt the processor and press <F6> to reset. The program memory
now shows a green arrow pointing to the line of code at address 0.
The instruction at this location is goto 0x000100. This code is added by the linker to
make the program branch to the start of the code in the Lab1.c file. From location
0x000100 executable code starts.
• Press <F7> to single step the code. The green arrow now points to the code
below _reset in the SMPS_PID_Control.s source code, as shown in
Figure 3-17.
• Right click two lines below the green arrow and choose “Run to Cursor”. The
green arrow then points to the line on which you right clicked.
• From the View menu, select View>Watch
Figure 3-18.
•From the Add SFR pull-down list, display DTR1.
•Click Add SFR to add the DTR1 register to the Watch window.
• Next, select PWMCON1 from the pull-down list and click Add SFR.
• Repeat for the ADCON register.
• You will be able to view these registers change as you step through the code.
• To set a breakpoint, right click a code line and select “Set Breakpoint” from the
pop-up menu.
As an example, find the following line of code and set a breakpoint on this line.
cp0VIN_GOOD_FLAG
A red stop sign should appear in the gutter (gray bar on the left) of the source
code window, as shown in Figure 3-19.
• Press <F9> to run the code. The program halts on the instruction following the
breakpoint
Note:An alternate method is to simply double click the line. This feature may
The dsPIC30F2020 device supplied with the dsPICDEM™ SMPS Buck Development
Board is pre-programmed with a demonstration program that illustrates simultaneous
Proportional-Integral-Derivative (PID) control of the output voltage for the two buck circuits on the dsPICDEM™ SMPS Buck Development Board. This code is available on
the CD that is provided with the dsPICDEM™ SMPS Buck Development Board kit. It
can also be downloaded from the Microchip web site (www.microchip.com).
This section covers the following topics:
• Demonstration Program
• Demonstration Code
• Other Code Examples
4.1DEMONSTRATION PROGRAM
The demonstration program provides simultaneous closed-loop control of the output
voltage from both buck circuits on the dsPICDEM™ SMPS Buck Development Board.
One PID loop controls a target voltage output (VOUT1) at 5V. The other PID loop controls a target voltage output (VOUT2) at 3.3V.
The PID control scheme consists of seven parameters. The main parameters are:
1. Proportional Error Gain (P-Gain) – This parameter produces a correction fac-
tor that is proportional to the magnitude of the output voltage error.
2. Integral Error Gain (I-Gain) – This parameter uses the cumulative voltage error
to generate a correction factor that eliminates any residual error due to limitations
in offset voltages and measurement resolution.
3. Derivative Error Gain (D-Gain) – This parameter produces a correction factor
that is proportional to the rate of change of the output error voltage, which helps
the system respond quickly to changes in system conditions.
Additional control parameters that are summed with the P, I, and D Gain terms are:
4. Second Derivative, or Jerk Error, Gain (J-Gain) – This parameter produces a
correction factor that is proportional to the change in the differential error (i.e., the
derivative of the derivative). J-Gain is a high frequency term that tends to provide
quick response to an impulse event.
5. Feed Forward Gain – This parameter produces a correction factor based on the
desired output voltage that is computed based on the magnitude of the input voltage, inductor current, and circuit attributes (i.e. inductor and capacitor values).
This term allows the control loop to be proactive rather than reactive. In other
words, when the input voltage changes, feed forward gain responds so that the
control loop does not have to wait until the output voltage changes before making
the appropriate gain correction.
6. Dead Time Gain – This parameter produces a correction factor, which compen-
sates for the fact that the feed forward gain term does not account for the energy
lost due to the dead time of the PWM signal (the time when both MOSFETs are
off).
7. Current-Limit Gain – This parameter limits the cumulative control gain when the
The demonstration program requires no manual preparation except to connect 9V
power to the board. You can verify the VOUT1 and VOUT2 voltage levels by measuring
them at the output terminals (J1 and J3, respectively).
If you installed the software that came on the dsPICDEM™ SMPS Buck Development
Board CD, the demonstration program source code is located in the following folder on
your PC.
Instructions for programming the dsPIC30F2020 are provided in the Readme file that
is included in the DualBuck folder. Chapter 3 also describes how to program the
dsPIC30F2020 using the ICD 2. Figure 4-1 illustrates the program flow of the
demonstration program.
FIGURE 4-1:SMPS DEMONSTRATION PROGRAM FLOW CHART
START
Initialization Routines:
• Peripherals – ADC, PWM, Timers, GPIO, etc.
• Variables – PID Gain Terms, Data Buffers
• Constants – Desired Voltage, Current Limit, etc.
• Interrupts – ADC, Timers
• Set Soft Start Flag
• System Stabilization
Soft Start Routine
Soft
Start
Routine
Yes
Idle Loop Functions:
• Check VIN
• Check Soft Start Flag
• Check/Reset Fault Timers and Flags
• Perform non-critical functions here (e.g. user
application tasks)
When power is applied to the board, the program starts by executing these system
initialization routines:
• Peripherals – The required peripherals (PWM, ADC, Timers, GPIO) are
configured and enabled.
• Variables – Program variables are defined. RAM locations and register usage are
also defined and documented.
• Constants – Program constants are defined, including reference setpoints for
both VOUT1 and VOUT2, input voltage, current limits, fault conditions, PWM
periods and Timer periods.
• Interrupts – The ADC and Timer Interrupts are set up and enabled.
• Soft Start – The Soft Start flag is set
• System Stabilization – All outputs are discharged to ensure a stable value at
startup.
4.2.2Fault Check
The program checks the ADC for input undervoltage and output overvoltage conditions. If a fault occurs, the PWM outputs are disabled until the fault condition is cleared.
If no fault is detected, the program proceeds.
Demonstration Program Operation
4.2.3Soft Start
If the Soft Start flag is set, the Soft Start Routine ramps up the output voltage in an
open-loop fashion to bring the system within the operating range of the PID control
loop. This routine ensures that the output does not overshoot the desired voltage. It
also limits the current at startup.
4.2.4ADC Interrupt
The ADC Interrupt is the heart of the demo program. This routine takes up approximately 75% of the execution time. It performs all the PID calculations and applies any
needed corrections to the output
Two simultaneous PID loops are being processed (one for VOUT1 and the other for
VOUT2). Each loop has its own variables, constants and peripheral initialization.
Key points to note are:
• The ADC Interrupt can occur at any time during program execution, and
• It takes priority over any other tasks that the program is performing.
4.2.5System Idle Loop
All auxiliary functions are performed in the System Idle routine. This is the time available to the CPU while the demo program is waiting for an ADC Interrupt. Non-critical
functions can be performed in this loop. During this time the input voltage, fault timers
and Soft Start flag are checked.
There are several other code examples included on the dsPICDEM™ SMPS Buck
Development Board CD. Please refer to the Readme files located in each code example folder for details on what each code example demonstrates. Check the Microchip
website (www.microchip.com) for the latest updates to these code examples and for
additional code examples.