Lab 0. Setup

Last modified by Microchip on 2026/04/08 10:28

Purpose

In this lab exercise, you will install the necessary software tools, then create and build a new standalone dsPIC33A project using MPLAB® Tools for Microsoft® VS Code®.

Lab 0 main.c

This procedure was captured using a fresh Windows® 11 installation, but it will be similar on other platforms.

Overview

This lab exercise is divided into the following sections:

Procedure

Part A. Install the MPLAB® XC-DSC C Compiler

The first step is to install the MPLAB XC-DSC C compiler on your PC. You can install a free licence to develop applications for any dsPIC33A device in VS Code.

Download the MPLAB XC-DSC C compiler installer for your OS.

Open a browser and navigate to the MPLAB XC-DSC Compiler landing page.

Navigate to the version for your OS and click the Download link.

MPLAB XC-DSC Compiler downloads page

Back to Top


Run the MPLAB XC-DSC C compiler installer.

Click Next to begin.

Setup window Next button

Accept the license agreement, then click Next.

Setup window Accept agreement

Select the Free licence type, then click Next.

Setup window license type

Leave the installation directory at the suggested default shown, then click Next.

Setup window installation directory

Set additional compiler settings, then click Next.

Setup window Compiler Settings

Click Next to install the compiler on your computer.

Setup window Ready to Install Compiler

Wait for installation to complete.

Setup window installing

Click Next to activate the free license.

Setup window Installation Complete

Click Finish to complete the compiler installation.

Setup window Finish

Back to Top

Part B. Install VS Code®

The next step is to install VS Code on your computer and create a unique profile for developing projects based on MPLAB tools.

In a browser tab, navigate to the Visual Studio Code home page and click the Download button to download the VS Code setup wizard for your PC.

Visual Studio Code download page

Back to Top


Run the VS Code Setup wizard.

Accept the license agreement, then click Next.

Visual Studio Code setup window license agreement

Accept the default installation directory, then click Next.

Setup window Select Destination Location

Click Next to set the default program shortcut location.

Setup window Select Start Menu Folder

Select the following additional tasks, then click Next.

Setup window Select Additional Tasks

Click Install to begin installation.

Setup window Ready to Install

Wait for installation to complete.

Setup window Installing

Close the Setup wizard...and do not select Launch Visual Studio Code. Press Finish.

Setup window Finish

Back to Top


Create a custom profile in VS Code for projects based on MPLAB tools.

Note: VS Code Profiles enable users to create and manage distinct, personalized setups within a single VS Code installation. Profiles allow for separate configurations of extensions and other settings, such as themes, font size, and zoom level, among others. Each profile operates independently and allows tailored environments for specific project types.

Start VS Code by searching for "VS Code" in the search bar and selecting Visual Studio Code as shown:

Visual Studio Code app on Windows search

Create a custom profile to use for developing projects with the MPLAB development ecosystem.

Click on the Manage gear icon in the lower-left corner, then select Profiles:

Walkthrough: Setup VS Code

Create a New Profile:

New Profile

Name it "MCHP Dev", then click Create to save the profile.

MCHP Dev profile

Switch VS Code to run under the newly created MCHP Dev profile.

MCHP Dev profile

You should notice the manage icon is now updated to indicate the MCHP Dev profile is active:

manage icon

Enable auto-save for edited files in this profile. This will be useful in later lab exercises.

Select File > Preferences > Settings:

File > Preferences > Settings menu

In Settings, search for "auto-save" and select afterDelay in the pull-down window:

auto save drop down

 

 You are now ready to install the MPLAB Extensions in this new profile!

Back to Top

Part C. Install MPLAB Extensions for VS Code

The next step is to install the MPLAB Extensions for VS Code into the custom profile you created in Part B.

Install MPLAB Extensions for VS Code.

Ensure the MCHP Dev profile is enabled in VS Code (see Part B, Step 3.3 for instructions).

manage icon

Click on the Extensions icon in the Activity Bar on the left side.

Extensions pane

Notice that there are currently no extensions installed in this profile.

Search for "MPLAB" and install the base MPLAB Extensions Pack shown here. This installs all 13 extensions that are a part of the MPLAB Extensions for VS Code.

Search for "MPLAB"

Select Trust Publishers & Install:

Trust Publishers & Install popup

When complete, click on the base MPLAB Extension Pack to display the version and other details about the extension.

version and other details about the extension

You are now ready to create your first project for dsPIC33A!

Back to Top

Part D. Install Microsoft® Serial Monitor Extension

This extension provides a built-in serial terminal function, which is useful for debugging C projects using the standard I/O functions, printf() and scanf().

Install the Microsoft Serial Monitor Extension for VS Code.

Ensure your MCHP Dev profile is enabled in VS Code.

manage icon

 

Open the Extensions view and search for "Microsoft Serial Monitor" as shown. Click on Install to install the extension.

search for "Microsoft Serial Monitor"

Upon successful installation, you will notice a new SERIAL MONITOR tab in the output window section of VS Code:

SERIAL MONITOR tab in the output window section

 

 

Back to Top

Part E. Create a New dsPIC33A Project in VS Code

Using the Create New Project command, we will create a new project using MPLAB Tools in VS Code. We select a dsPIC33A device and toolchain, and then build the project.

Run the MPLAB: Create New Project command.

Open the VS Code Command Palette.

In VS Code, open the Command Palette by using the key combination Ctrl + Shift + P

VS Code Command Palette

 

Select the MPLAB: Create New Project command.

Type "MPLAB: Create New Project" and hit enter when you see the full command displayed.

MPLAB: Create New Project command

Back to Top


Follow the Create MPLAB Project prompts.

Specify the project name. Name the project "lab0" and hit enter

Name the project lab0

Select Custom Location.

project location

Create folder C:\projects\dspic33a and select this folder to hold the project:

Create folder

 

Select a device.

Find the device by typing "dsPIC33AK512MPS512", then selecting it from the drop-down.

Find dsPIC33AK512MPS512

Select the project type.

Select the Standard application project type as shown.

Select the project type

 

Select the toolchain.

Select the XC-DSC installation from Part A.

Select the toolchain

When prompted, enable trust for the authors of all files in the parent folder. Select Yes, I trust the authors:

enable trust for the authors

Several background processes begin to execute, installing CMake®, Java® (if needed), MPLAB USB Drivers, etc. When prompted to download the dsPIC33AK pack, select Yes.

installing CMake, Java (if needed), MPLAB USB Drivers

When you see the following Windows Security pop-up, select Allow:

Windows Security pop-up

When you see _build, .vscode, and cmake sub-folders created in the project Explorer view, the project is ready to be built!

sub-folders

Back to Top


Build the created project, then close it.

Click on main.c in the Explorer view to open it. You will see a complete main() function.

main.c file

Build the project.

Use the Ctrl + Shift + B key combination to build the project. If asked to select a build task, select the build task named after your project and default configuration (in this case, it should be lab0: default - Build).

lab0: default - Full Build

Verify that you get a build success output from the build in the VS Code terminal:

VS Code Terminal

Alternatively, you can build the project by selecting the project properties icon in the Activity Bar, then clicking on the hammer icon in the project properties view, as shown here:

project properties view

 

Select File > Close Folder to close the project:

File > Close Folder menu

To re-open the project, select File > Open Folder and navigate to the C:\projects\dspic33a\lab0 folder. 

Back to Top

Results

At this point, you should be able to create a basic, working project using MPLAB tools with a selected device and toolchain. When you build the project, you should get a "CMake Build successful" message in the terminal.

If you open the Explorer view, you should find the following files:

Explorer view

  • a project file, lab0.mplab.json, is located in the .vscode folder
  • a simple main.c file that you can modify and rebuild
  • output default.elf of your build in the out folder, and
  • a default README.md file that contains a description of the files in the project.

Next Project

  • Start Lab 1 to learn about basic digital I/O pin configuration on dsPIC33A, as well as how to perform programming and debug operations in VS Code.