
Explore using the low-cost pic32cm mc microcontroller evaluation kit for power electronics, programming in c with mplab x and xc32, and implementing gating, timing, and analog feedback control.
Engineers entering the power electronics industry learn to program the PIC32 CMC microcontroller in C using essential peripherals like pwm, timers, digital outputs, and analog inputs, with hands-on labs.
Identify the hardware requirements for this course, including the Curiosity Nano kit with the Pic32 cm microcontroller, headers, oscilloscope, and basic components for live coding and PWM experiments.
Understand the software requirements for the PIC32CM MC course, focusing on essential C programming and data structures, and set up Windows 11 with MPLAB X IDE and X32 compiler.
Watch videos and engage in this hands-on course. Install mplab x ide and the mplab x 32 compiler, study the pic32 cm microcontroller documentation, and use the Q&A forum.
Install MPLAB X IDE, install a 32-bit compiler, access starter projects, run LED project, explore Microchip GitHub for example code, review project structure, and learn electronics best practices and safety.
Download and install MPLAB X IDE and the XC32 compiler for 32-bit PIC32CM microcontrollers. Configure default paths and proxy options, then verify the development environment is ready.
Download the starter project for the pic32cmc curiosity nano kit. The LED toggle demo uses a timer and gpio to flash a yellow LED and print the rate.
Discover microchip's github resources, including CSP chip support package and application examples for pic32cm mc family, with starter projects for curiosity nano kit covering pwm, adc, and timers.
Open the getting started project in MPLAB X IDE, program the microcontroller kit via make and program device, and verify a flashing LED and time interval changes using the switch.
Explore the pic32 getting started project structure in Mplab x id by examining header and source files, config files, and include directories, and learn navigation with ctrl-click to locate functions.
Download the PIC32 CCM 1216 MC microcontroller datasheet and nano kit user guides to learn GPIO pin mappings and how header and source files organize peripherals in the project explorer.
Prioritize safety in your home lab: unplug before touching, avoid changes while energized, wait for capacitors to discharge, and verify voltage and current limits with pencil analysis, simulators, and datasheets.
Learn to configure GPIO pins as digital outputs on a microcontroller, implement a basic LED blink using the Getting Started project, and explore C basics and project structure with headers.
Explore the PIC32CM Cortex-M0+ microcontroller architecture, including memory, buses, and peripherals such as GPIO, PWM, ADC, and motor control features for power electronics applications.
Explore gpio pins and peripheral functionalities on the 32-pin microcontroller, including groups A to J, pin mapping, and safe selection for adc, dac, and analog comparator.
Copy the getting started project to a new test gpio folder. Rename the project in MPLAB X IDE and review main.c and header files to study the gpio port module.
Configure gpio pins as outputs using the port module, using dir set/clear/toggle and out set/clear/toggle registers, and select peripheral functions via pin config and p mux registers.
Explore the PIC32CM MC microcontroller header structure to access port module registers and GPIO pins. Learn how memory-mapped peripherals and the main chip header organize definitions.
Navigate the PIC32CM getting started header, and use port initialization to configure port dir and port out registers, mapping PA23 to an LED and PA22 to a switch.
Access port registers using a pointer and the arrow, then access members with dot notation. Configure pins via pin config and p mux registers to assign peripherals per pin map.
Clean up the base starter project by trimming unused peripherals and refocusing on gpio-based output, preparing a dedicated test gpio project for driving leds and connecting external circuits.
Connect three LEDs to GPIO pins PA8, PA9, and PA10 on the evaluation kit using 2 kΩ current-limiting resistors to limit current from 3.3 V.
Configure leds on gpio pins pa eight, pa nine, and pa ten as outputs using dir set register. Implement high and low drive functions to glow or reset leds.
Compile the project to detect issues using clean and build options. Remove unused stdio buffer mode set function to fix the compiler option error and achieve successful compilation.
Program the microcontroller by wiring a breadboard, configuring GPIO pins 8-10, and driving red, white, and blue LEDs to validate initialization, then toggle pins high and low to test outputs.
Conclude the gpio module by reviewing a working project, exploring header files and register structures, and preparing to extend with timers, pwms, and adcs in future sections.
Explore configuring the timer counter module on the pic32cm mc, generate clock signals from oscillators, enable peripherals, set waveforms, and generate interrupts; extend projects from GitHub using technical documentation.
Explain the Pic32 MSI timing system, including onboard oscillators, exos options, a PLL for 96 MHz, and configuring nine Gclc generators to feed the main clock and peripherals.
Explore how to configure the 48 MHz on-board oscillator, adjust the division and calibration, read sync status, and compare high performance with low power using 32 kHz timing options.
Configure the 32.768kHz on-board oscillator: enable the oscillator 32 K, check the status, apply calibration, and optionally use interrupts for stable timing with the RTC and the 48 MHz clock.
Explore how generic clock generators in the PIC32CM microcontroller provide clocks with nine GCLK generators and selectable sources (48 MHz, 32.768 kHz, external, or GCLK io pins) for peripherals.
Learn how the main clock generator feeds the CPU and peripherals via the Gclc main clock, Ahb and Apb buses, and mask registers to enable modules.
Configure the timer counter module on the pic32cm, pairing tc0 with tc1 or tc2 with tc3 for 32‑bit timing, set clocks and prescalers, and generate end‑of‑interval interrupts using cc0.
Learn how the nested interrupt vector controller handles peripheral interrupts from modules like Tse, pwm, and adc, and how the vector table routes to the correct interrupt service routines.
Explore clock setup and the PIC32CM timer counter module through GitHub timer mode demos, and see LED blink every second.
Explore how the example project initializes the system, clocks, and registers the timer interrupt that toggles an LED in main.c.
Configure clocks and gclc generators, and access the gclc and oscillator control registers. Explore header files and tc0 initialization for pwm, prescalers, and timer interrupts.
Understand how the Tc0 timer overflow interrupt is configured, registered via a callback, and handled through a vector table, with the interrupt service routine toggling the LED.
Copy and rename a base project to start a new one, then create a tc directory under peripherals and add the header and source files to the project.
Create a project structure with directories and header files, integrate the tk library, and configure a dual-clock setup with 48 MHz and 32.768 kHz oscillators.
Learn how to initialize and calibrate a 48 MHz oscillator for the PIC32CM MCU using calibration 48 and oscillator control registers, with sync busy and oscillator ready to confirm readiness.
Rewrite to set up the 32 kHz oscillator by casting to uint32, extracting calibration bits, applying a left shift by 16 bits, enabling the oscillator, and polling the ready status.
Set up Gclc generator zero and generator one by selecting 48MHz and 32kHz sources, configure generator control registers, and wait for synchronization to finalize clock deployment.
Configure the Gclc generator one for a 32 kHz clock, manage synchronization, and enable Tc0 to Tc4 through peripheral channel control to create a 32-bit Tc0/Tc1 and 16-bit counters.
Finalize the clock initialization by configuring the main clock generator and APBC mask, enable Tc0 to Tc4, and outline the next steps for Tse zero and Tse three modules.
Expand the Tse module library by creating header and source files for Tse1–Tse3, update include guards, and add them to the definitions so peripherals are recognized during initialization.
Configure and initialize the 32-bit tc0/tc1 timer module by rewriting control registers, performing a software reset, and setting 32-bit mode with no prescale clock for precise timing.
Configure tc0 timer with a match frequency waveform, set cc0 top value for the period, wait for sync busy, and enable the overflow interrupt, with tc3 as an alternative.
Configure tc3 as a 16-bit counter using a 48 MHz clock, adjust prescaler and waveform to achieve a one-second interval, and explore slower clock options via the Gclc generator.
Configure and initialize timer modules tc0, tc2, tc3, and tc4, enable their interrupts via the nvic, and register interrupt service routines with callbacks for responsive timer-based events.
Rewrite interrupt handlers to clear the overflow flag and reset the int flag, then replace dummy vector table entries with the actual tc0_handler, tc2_handler, tc3_handler, and tc4_handler.
Implement four gpio toggle routines inside the interrupt service routines, wire them to the timer interrupts, and enable tc0 through tc4 timers with proper register updates and synchronization.
Learn how to compile the PIC32CM MC power electronics project, fix initialization and interrupt prototype errors, and achieve a successful build before testing with LEDs and an oscilloscope.
Execute the timer project on the microcontroller, download the code, and verify 1 ms, 0.5 s, and 1 s intervals using the oscilloscope and LED outputs.
Recap how clocks are generated with oscillators and GCLKs, configure the tick timer counter and NVIC interrupts, and validate via LEDs and oscilloscope while previewing the PWM extension.
Generate pwm waveforms with the tcc module for power electronics in PIC32CM MC microcontroller, and implement configuration, library usage, and interrupt service routines for converter modules using technical documentation.
Explore the DCC module setup, clock configuration, and TCC zero’s eight outputs with dead time to generate PWM for a converter, using single-slope/dual-slope carriers and an output matrix.
Learn waveform generation on the PIC32CM MC for power electronics, covering seven PWM modes, period and capture registers, and center-aligned modulation options.
Explore how the DCC module's waveform extension control register maps capture compare registers to eight output pins via the output matrix and how drive control enables inversion for complementary outputs.
Learn to generate pwm interrupts with the tcc module to start control every pwm cycle, using overflow interrupts and dual-slope options via the interrupt enable set register.
Explore the control and status registers of the tcc module, including resolution bits, prescalers, wraparound, and random noise injection to refine pwm, plus safe writes with sync busy checks.
Explore a GitHub example of a TCC synchronous pwm project generating 2- or 3-phase pwm with dead time for motor control, and learn to read and adapt the code.
Extend the gpio project into a tcc module by adding tcc library files and headers. Organize test pwm and test gpio folders and include tcc sources in peripheral directory.
Select gpio pins as Tc0 waveform output pins to generate pwm pulses and insert dead time between converter legs, using the pin map to choose A8–A17 available on the kit.
Configure TCC WO pins by turning gpio pins into peripheral pins via pin config and p mux, selecting the e or f group per the port map for pa8–pa17.
Configure the PIC32CM MC clocks by selecting a 48 MHz oscillator or a 32.768 kHz oscillator, initialize gclk generator zero and one, and enable the TCC zero clock.
Reset the Tc0 module and disable it if running, then configure the prescaler and period to achieve a 5 kHz pwm using a 48 MHz clock (9600 counts).
Learn to configure the PIC32CM MC waveform generator for PWM, choosing a triangular waveform via the wave register with DDS bottom and beginning-of-cycle interrupt.
Set the pwm period by loading the period register with half the target time. Initialize the four capture resistors cc0–cc3 to produce distinct pulse widths on output pins.
Learn how to verify register writes by checking sync busy flags on the PR and CC registers, ensuring each write completes before continuing.
Register the TCC0 pwm interrupt callback in the main program and implement a streamlined isr that clears the overflow flag and invokes the callback.
Initialize the nested vector interrupt controller, assign TCC0 interrupt line 13 with a priority, and update the vector table to connect the PWM overflow interrupt service routine.
Enable the TCC0 module on the PIC32CM MC microcontroller by setting the control register enable bit, await sync, then register and start the interrupt service routine for power electronics timing.
Diagnose and fix a genuine compilation error in a PIC32CM project by aligning the TSI timer status to uint32, then build cleanly and verify success before wiring the microcontroller kit.
Execute the project on the Curiosity Nano to observe PWM waveforms on GPIO pins via capture-compare registers, verify with the oscilloscope, and discuss dead time between complementary gate pulses.
Use the drive control register to invert the upper output pins and create complementary waveforms via invert enable and waveform output inversion.
Execute the microcontroller project to generate complementary PWM waveforms by inverting the upper output pins and verify complementary signals with an oscilloscope, with dead time module to be covered next.
Only the tc0 module provides dead time insertion, generating complementary gating signals for converter legs by applying dtls and dths between eight pins (wo0/wo4, wo1/wo5, etc.).
Enable the dead-time bits in the wave extension control register, then calculate and write 32-bit values to the Dhs and Dtls fields to set the delay.
Execute the project and verify dead time between the gating signals and the complementary gating signals, using the dead time generator to produce a practical PWM gating pulse.
Explore how the TCC module generates PWM gating signals with an output matrix and dead time, and extend PWM to unipolar and three-phase converters.
Explore how the PIC32CM ADC converts analog signals to digital values for closed-loop control, using PWM, triggers, and the event system, with accuracy verification and hands-on coding.
Introduce the PIC32CM ADC module, detailing two independent ADC blocks with separate sample-and-hold and result registers. Explain 8/10/12-bit modes, single-ended and differential inputs, and optional scheduled conversions with interrupts.
Configure the ADC module by enabling, resetting, and disabling as needed. Set prescaler and diff mode to control sampling, start conversions with the software trigger, and load calibration data.
Configure the analog-to-digital converter channels on the pic32cm mc using either the input control register for single or differential conversions, or the sequence control register for multi-channel sequencing.
Configure ADC zero and ADC one, choose channels and sampling modes. Read the 16-bit result register promptly, monitor the overrun bit via interrupts to prevent data loss.
Generate safe mock analog signals for the PIC32CM ADC using GPIO-driven sawtooth waveforms, conditioning circuits, and saturation to keep inputs within 0–3.3 volts.
Set up a test ADC project by adapting the PWM base project in MPLAB X IDE. Sample two analog inputs every PWM cycle using the ADC peripheral.
Choose analog input pins by consulting the pin map. ADC0 has most inputs, ADC1 has only two; for example, use PA2 and PA3 as analog inputs AIN0 and AIN1.
Bring in the timer counter (tc) module files, create the tc directory, add tc0 and tc common headers, and copy over timer project code for tc0 initialization to 50 Hz.
Configure pa24 and pa25 as outputs and initialize tc0 with a 32 kHz clock to generate a rectangular waveform, preparing RC circuit verification of a sawtooth signal.
Configure Tc0 by enabling its clock in the APC mask and set CC0 for a 0.01 second period to toggle the output, preparing NVIC interrupts for a 50 Hz waveform.
Enable the timer counter zero interrupt in the NVIC, assign its priority, register the ISR and callback, and place the handler in the interrupt vector table.
Enable the timer counter zero interrupt and toggle PA24 and PA25 using the out toggle register to generate a rectangular waveform every 0.01 seconds.
Execute the project to verify rectangular waveforms on gpio pins 24 and 25 using rc networks with 22.2k resistors and 3.3/4.7 μf caps, producing sawtooth signals for safe adc inputs.
Add the adc directory to the peripheral, copy plib adc common, adc zero header, and adc zero c file, and get ready to set up the clocks next lecture.
Choose pa2 and pa3 as analog inputs, configure them as peripheral pins, and map them via the pin mux to the adc zero module, reusing existing code.
Update the clock initialization to enable adc via gclc generator zero (48 mhz) and schedule adc zero conversions every pwm cycle within the 200 microsecond period.
Initialize the adc with the adc initialize function, reset adc zero, set the six megahertz clock by dividing 48 mhz by eight, calibrate bias ref and bias comp.
Calibrate the adc module by correctly shaping bias comp and bias ref bits through shifts, casts, and register updates, then verify synchronization and set single ended mode.
Configure adc input channels using the sequence control register, enabling analog inputs 0 and 1 by writing 3, and set a five adc clock sample hold window.
Enable the ADC interrupt for the ADC zero module by setting the interrupt when the result is ready in the result register. Register the ADC zero interrupt service routine.
Enable adc interrupt in the nvic, update vector table with the adc zero ISR and priority, then start the adc and update the modulation index for next cycle using results.
Enable the ADC module and set the enable bit in control A, then trigger the start of conversion via the software trigger during the PWM interrupt.
Extract two converted ADC values in the ISR via sequence status and control registers, store them in an array, mask to 12 bits, and reset the sequence counter for repeats.
Extract results into a 16-bit unsigned array matching the sequence control bits for the sampled channels. Convert to floating point and scale by 3.3/4095 for each sample before control calculations.
Configure two GPIO outputs, compare larger and smaller sawtooth inputs, set and clear P4 and P5 based on crossings, and verify the conversion process with oscilloscope measurements.
Compile the project for the PIC32CM MC microcontroller, fix include errors by adding the ADC module to definitions.h, and perform a clean build to ensure compilation and readiness to execute.
Fix a subtle adc reference bug by setting the reference to 3.3V instead of the default 1.024V. Use the ref control to select avdd and write 0x5 for accurate results.
Verify ADC operation on the microcontroller kit by sampling sawtooth waveforms with PA2/PA3 as analog inputs, and compare against 2 V and 1.5 V thresholds while watching with an oscilloscope.
Discover the PIC32 event system module, a fast, communication fabric with 12 channels that lets a single event generator per channel talk to multiple listeners, without CPU intervention.
Configure the event system by enabling channels and selecting an event generator and listener, using asynchronous paths for inter-module communication between the TCC0 module and ADC module to start conversion.
Initialize system clocks by configuring gclk generator zero (48 mhz) and enabling event system channel zero on peripheral channel six; enable APK clock and note HB mask is unused.
Initialize the event system and configure channel zero with Tc0 overflow as generator and ADC zero start of conversion as listener, then connect to ADC0 and TCC0 modules.
Update the TCC0 module to generate events on overflow instead of interrupts, wiring channel zero to the ADC SoC user and configuring the event control register for overflow output events.
Enable the ADC0 event control register to start conversions on the Tc0 overflow event, enabling event-driven ADC triggering, and streamline the code by removing the unnecessary interrupt service routine.
Compile the project as the main project with a clean build. Verify the event system module and use event-driven ADC startup with no interrupt service routine, with the TCC module.
Execute the project on the same microcontroller setup, verify sawtooth waveforms with the oscilloscope, and confirm the event system replicates the interrupt flow while reducing processor burden.
Conclude this section by reviewing adc module configuration, analog input setup, register settings, and extracting results for control, and highlight the event system that enables adc-pwm communication and signal conditioning.
This course teaches microcontroller-based hardware implementations for power electronics, highlighting timer counter modules, ADC sampling, PWM gating signals, and feedback control with PID and PI algorithms.
The course will describe how to use the PIC32CM1216MC00032 microcontroller from Microchip for power electronics applications. The PIC32CM MC microcontroller is a very popular low-cost microcontroller used in the power industry for various applications such as motor control and power factor correction. The purpose of this course is to provide young engineers with exposure to microcontrollers used in industry, and help them land their first jobs as power electronics engineers or firmware engineers. The course can also be used as training material by companies to train their engineers in using PIC32 microcontrollers from Microchip. The course covers both theory and programming, with details on the architecture of the microcontroller and its peripherals, as well as code sessions where projects are built from the ground up. The projects are accompanied by experiments with the results being observable either through blinking LEDs or through waveforms on the oscilloscope.
The course describes how students can setup a low-cost electronics lab with components available from online marketplaces. The microcontroller kit (Curiosity Nano Evaluation Kit) needed for the course is readily available in many online marketplaces and costs merely USD 16. The course will begin with very simple examples such as how to make LEDs glow and flash. The course will then progress towards generating Pulse Width Modulation (PWM) gating signals and using the Analog to Digital Converter (ADC) for closed-loop control. The course will use the MPLAB X IDE and the MPLAB XC32 compiler provided for free by Microchip, and also example projects and starter files available on the Microchip website and GitHub page. The course will describe how necessary software can be downloaded and how the student can interpret and understand the example projects.