Lab 0. Setup
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®.

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:
- Part A. Install the XC-DSC Compiler
- Part B. Install VS Code
- Part C. Install MPLAB Extensions for VS Code
- Part D. Install Microsoft Serial Monitor Extension
- Part E. Create a New dsPIC33A Project in VS Code
- Results
- Next Project
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.

Run the MPLAB XC-DSC C compiler installer.
Click Next to begin.

Accept the license agreement, then click Next.

Select the Free licence type, then click Next.

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

Set additional compiler settings, then click Next.

Click Next to install the compiler on your computer.

Wait for installation to complete.

Click Next to activate the free license.

Click Finish to complete the compiler installation.

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.

Run the VS Code Setup wizard.
Accept the license agreement, then click Next.

Accept the default installation directory, then click Next.

Click Next to set the default program shortcut location.

Select the following additional tasks, then click Next.

Click Install to begin installation.

Wait for installation to complete.

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

Create a custom profile in VS Code for projects based on MPLAB tools.
Start VS Code by searching for "VS Code" in the search bar and selecting Visual Studio Code as shown:

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:

Create a New Profile:

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

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

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

Enable auto-save for edited files in this profile. This will be useful in later lab exercises.
Select File > Preferences > Settings:

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

You are now ready to install the MPLAB Extensions in this new profile!
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).

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

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.

Select Trust Publishers & Install:

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

You are now ready to create your first project for dsPIC33A!
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.

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

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

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.

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

Follow the Create MPLAB Project prompts.
Specify the project name. Name the project "lab0" and hit enter.

Select Custom Location.

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

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

Select the project type.
Select the Standard application project type as shown.

Select the toolchain.
Select the XC-DSC installation from Part A.

When prompted, enable trust for the authors of all files in the parent folder. Select Yes, I trust 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.

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

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

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.

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).

Verify that you get a build success output from the build in the 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:

Select File > Close Folder to close the project:

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:

- 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.