Example Code for dsPIC® Digital Signal Controllers (DSCs)

Last modified by Microchip on 2024/02/16 08:21

Code Example Home Page

Browse Microchip's document listing page for code examples.

CE020 - Standard Mode Pulse-Width Modulation (PWM) Using dsPIC® Digital Signal Controller (DSC) Switch Mode Power Supply (SMPS)
This code example illustrates the use of the Power Supply PWM module in the Standard PWM mode. This example is intended to provide a setup guide for using this mode. PWM1H and PWM2H are configured to be digital outputs, and PWM1L and PWM2L are selected as PWM outputs. PWM2L is also configured with a phase shift of 250 ns from PWM1L.

CE025 dsPIC DSC SMPS Negative Deadtime Example
This program illustrates the use of Negative Dead-time in the PWM module in the dsPIC30F1010/202x SMPS family with ADC triggers. The PWM outputs are configured with negative deadtime and configured to generate ADC triggers. PWM1 generates a trigger on ADC channel 5 while PWM2 triggers ADC channel 6 on alternate PWM cycles, and in the middle of the PWM period. The converted ADC value is used to update the duty cycles of PWM1 and PWM2. The voltage at AN5 decides duty cycle of PWM1, while the voltage at AN6 decides duty cycle of PWM2.

CE026 dsPIC DSC SMPS ADC Early Interrupt
This code example sets up ADC pair 0 (AN1,AN0) conversion to be triggered by the software trigger. The Early Interrupt feature is enabled. In this example, the FRC with Hi-Range is set up to run at frequency of 14.55 MHz. This will result in Fcy = 29.1 MHz. The input clock to the ADC clock divider will be Tcy = 34.364 ns.

CE157 Cycle by Cycle PWM Fault
This code example shows how to program the cycle-by-cycle fault operation in the dsPIC33FJ SMPS family. Comparator 1 (CMP1A, pin 21) is used as the comparator input. A high value on this pin triggers the fault operation. As a consequence, the PWM output is disabled. As soon as the fault signal is removed, the PWM output will be immediately active again.

CE159 PWM Push Pull Mode
This code example illustrates the use of the Push-Pull mode of the Power Supply PWM module. PWM1 and PWM2 are set up to produce 50% duty cycle with a PWM period of approximately 500 ns. The Push-Pull mode produces a pulse on PWMxH on one cycle and PWMxL on the next PWM cycle. Therefore the PWM duty cycle may appear smaller than 50% (effectively 25% in this example).

CE160 Standard Mode PWM
This code example illustrates the use of the Power Supply PWM module in the Standard PWM mode. This example is intended to provide a setup guide for using this mode. PWM1H and PWM2H are configured to be digital outputs, and PWM1L and PWM2L are selected as PWM outputs. PWM2L is also configured with a phase shift of 250 ns from PWM1L.

CE161 True Independent PWM Output Mode
The dsPIC SMPS family of Digital Signal Controllers features an on-chip Power Supply PWM Module. This module supports several PWM modes typically used in Power Conversion applications. This example is intended to provide a setup guide for using this mode.

CE162 Complementary PWM Mode
This program sets up the PWM module for complementary mode operation. The PWM1 and PWM2 outputs are configured to produce a 400 kHz PWM signal with a duty cycle of 26%. PWM2 is phase shifted by 250 ns.

CE163 PWM with Negative Deadtime
This program illustrates the use of Negative Dead-time in the PWM module in the dsPIC33F SMPS family with ADC triggers. The PWM is configured with negative deadtime and configured to generate an ADC trigger. PWM1 generates a trigger on ADC channel 5. The converted ADC value is used to update the duty cycle of PWM1. The voltage at AN5 (POT) decides the duty cycle of PWM1.

CE164 PWM with Independent Fault Mode
This file contains the following sections:

  1. Code Example Description
  2. Folder Contents
  3. Suggested Development Resources
  4. Reconfiguring the Project for a Different dsPIC33F device
  5. Revision History

CE168 Current Reset/Variable frequency Mode
This code example illustrates the use of the Power Supply PWM module as current reset/variable frequency mode with the help of the high-speed Analog Comparator. This example is intended to provide a setup guide for using PWM in the current reset/variable frequency mode of operation.

CE169 PWM Capture Function
This code example illustrates the use of the Power Supply PWM module PWM Capture mode. This example is intended to provide a setup guide for using PWMCAP register to capture the duty cycle value.

CE170 Center-Aligned PWM
This program sets up the PWM module for Center-Aligned mode operation. The PWM1 outputs are configured to produce a 400 kHz PWM signal with independent duty cycle. PWM1H produces a 50% duty cycle and PWM1L produces a 25% duty cycle. PWM2 outputs are configured to produce a 400 kHz PWM in complementary mode. The duty cycle of PWM2 is 50%.
 

Back to Top