Download the CST250template23.X.zip file from the class
reference area on the class website and store it in a folder on
your Z drive (i.e. Z:\CST250\labs). Note that it is best
to avoid spaces in file and path names. MPLab X may have
issues with spaces.
Then expand the CST250template23.X.zip file to the current
directory (i.e. labs). That is, right click on the zip file name
in Windows explorer and select Extract All. This should produce
a CST250template23.X folder containing a number of other files
and folders.
Open the MPLab X IDE program and use it to open the
CST250template23.X project. Use File > Open Project or use
the Open project Icon in the ribbon and navigate to the
CST250template23.X folder you extracted on your Z drive.
Right click on the CST250template23 Project in the MPLab X
"Projects" window (Window > Projects if it isn't already
open) and select "Rename...". Put an appropriate name
(i.e. Lab1a) in the Project Name box and (important) check the Also Rename
Project Folder box. Then click Rename.
Right click on the new project (i.e. Lab1a) in the projects
window and select "Set as Main Project".
Expand the "Source Files" item under the project name (i.e.
Lab1a) in the Projects window. Right click on the Intro.S file
and select rename and give it an appropriate new name (i.e.
Lab1a). Note that the extension (.S) will automatically be
retained. Note that while source files can have the same name in
two different projects, you might find that confusing.
Double click the Lab1a.S file to open it in the editor.
I recommend setting the "Debug Startup" option under Tools
> Options > Embedded > Generic Settings to "Halt at
Main". Otherwise the simulator will start your code in run
mode. Alternately you can make sure to set an appropriate
breakpoint before starting the session. Also set "Debug Reset @"
to Main as well (if it isn't already). Click OK.
Also, set the "Expand Tabs to Spaces" option under Tools >
Options > Editor > Formatting.
For the next project, you can repeat this process starting at
the second bullet, since the zip file should still be in the
labs folder.
Starting a New Project from scratch
Open MPLab X
Launch a new project from the File menu or using the New
project Icon in the ribbon.
In step 1, select "Standalone Project" from the
"Microchip Embedded" category. Click Next.
In step 2, select the PIC32MX360F512L device from the 32-bit
MCUs (PIC32) family. Also select the "Simulator"
hardware tool. Then click Next.
In step 5, (steps 3 and 4 are skipped) select (highlight)
the XC32 compiler toolchain:X C32 (v4.30) [C:\Program
Files\Microchip\xc32\v4.30\bin]. Click Next.
In step 6, select a project name and browse to create a new
folder on your Z drive (i.e. Z:\yourname\CST250\labs).
(Note that it is best to avoid spaces in file and path names
since MPLab X may have issues with spaces.) A project
folder with the same name as the project will be created in
the project location. Check the "set as main project" box.
Note that instead of using Z, you can create a folder on
the C drive, and project building might be faster if you do,
but that anything stored locally on the C drive will be lost
at the end of the day (or if the machine must be rebooted).
So, if you use the C drive you will have to copy files to and
from your Z drive (or another storage device) each time you
use the lab.
Click Finish.
Create a new assembly source file by right clicking on the
"Source Files" section of your project in the Projects window
and selecting New > Empty File. (If "Empty File" is not shown
as an option, select New > Other > Other > Empty
File.) In step 2 choose an appropriate file name for your
source code. It must end in .S
(dot capital-S). You don't need to select a new folder. Click
Finish. This should create and open an empty assembly source
file.
Put the following at the top of the source file you created:
/* Your name,
date and other project documentation here */
#include<p32xxxx.h> .global main .set noreorder .data .text main:
I recommend setting the "Debug Startup" option under Tools
> Options > Embedded > Generic Settings to "Halt at
Main". Otherwise the simulator will start your code in run mode.
Alternately you can make sure to set an appropriate breakpoint
before starting the session. Also set "Reset" to Main as well
(if it isn't already). Click OK.
Also, set the "Expand Tabs to Spaces" option under Tools >
Options > Editor > Formatting.
Next, select Project Properties (Right click on the project
name in the Projects window and select "Properties" at the
bottom of the pop-up menu, or File > Project Properties).
Then select "Building" under Categories and check the "Execute
this line before build" checkbox. Under that enter: "preasm
${SOURCEFILES}" (without the quotes). Click OK.
As discussed in lab, this will run a pre-assembly check on your
source code that limits the pseudo/macro instructions that you
can use to those found on the MIPS 32 Instruction Reference
handout. You can choose to skip this step, but be aware that I
will be deducting points from labs that don't pass the preasm
check.
Installing MPLab version 6.00 on
your computer
Note that
versions 6.05 -- 6.20 of MPLab X have a problem with its
variable and watch windows. You will want to download version
6.00 instead. This is the version currently installed in the
labs. We are also using version 4.30 of the xc32 compiler in
the lab.
Navigate to https://www.microchip.com/en-us/tools-resources/archives/mplab-ecosystem
. Find MPLAB X v6.00 in the "MPLAB X IDE Archives" section (you
can search for 6.00 in the search box at the top of this section
or go to the last page in the section). Click on the link
for MPLAB X v6.00 column for your operating system. Then install
it.
Note that version 6.00 is only available for 64-bit operating
systems. If you have a 32-bit OS, you will need to get version
5.35 of MPLAB X from the MPLABX IDE archives area.
Next, scroll down to find the "MPLAB XC32 Compiler
Archives" section of the page. Then, find, download and
install version 4.30 of the XC32 C-Compiler as
appropriate for your operating system.
Finally, also make sure to copy the preasm.zip file found on
the class reference material area and expand its contents into
the "Program Files\Microchip\MPLabX\v6.00\gnuBins\GnuWin32\bin"
directory. If you are doing an "Extract All" in Windows
explorer, remove the "preasm" directory from the end of the
folder path so that the files are extracted into the bin
directory itself and not into a new preasm directory under bin.
Note that this will only work on windows machines. Let me know
if you are using another operating system.