Useful Tools

contact us contact tutor/group email to a friend accessibility options report a fault
Microcontrollers

Microcontrollers

Practical Session 0:  MPLAB Tutorial


This tutorial will help you through the process of  using MPLAB to create a program.

You start a new program by clicking of the "File" drop-down menu item and selecting "New".  A new "Untitled" window will open and you will be able to start writing your assembly program inside this window.

When you have finished entering the program (or want to stop for a break) you need to save it.  Click on "File", then on "Save As".  In the "Save File As"  window, type the name of the file into the "File Name" box (and delete everything else).  You can also select the folder you want to save the file into as well.

You now need to create a PROJECT FILE.  This will be used to keep track of all the files you, and the MPLAB IDE, create for your program.

Assuming that you have created your .asm file, click on the "Project" drop-down menu item and then on "New Project".  Enter a name for your project (best to make this the same as your .asm file.)  and click on "OK".  Now, back in the Project window, click on "Edit Project", and a new window will appear.  


The only part you need to change is reached by clicking on the .hex file in the "Project Files" box.   (Don't worry that your .asm file is not yet included in this box - it will be later).  You should now see the following window.


This shows the default settings for MPLAB.   As it stands it will not create a  .hex file.  (Unhelpful, I agree).  So go to the "Hex Format" line and click on the INHX8M button to select this Hex file format.  You might also like to click  the "Off" button for "Case sensitivity"  as well.  Now click on "OK" and this window will close.
 


 


Back in the "Edit Project" window, click on the button for  "Add Node"  (which will be in BOLD now).  Select your .asm file and click on "OK".  Back in the "Edit Project" window, your .asm file name will now be displayed (as in the screenshot above).

You should now be able to open the "Project" window and use "Build All" to assemble and link your program.
 
 


Final Configuration Checks

 Select the "Options" drop-down menu and click on "Development Mode".

  1. Choose the "Tools"  tab and click on "MPLAB Simulator".  This will allow you to be able to see the ROM, RAM, and SFR windows.  (Explained later).
  2. Select the "Clock"  tab.     Click on "XT Clock".  It should be set to 4.00MHz.
  3. Select the "Configuration" tab.   Check that the "Watchdog Timer" is set to "None" (for development purposes).
    Check also  that "Processor Mode" is set to "Microcontroller".

Click on "Apply" and then on "OK" to save these settings.
 


 


After "Build All" you should be able to open up ROM, RAM, and SFR windows on the screen all at once, but they will overlap one another.  To make it possible to read all the windows, click on the "Window" drop-down menu and select the "Tile Horizontal" mode.

Now, click on the "Debug" drop-down menu item and select "Power On Reset".  In the window that opens,  click on "Randomize All Ram Locations" and then close the window.  This will make it easier to see what is changing in the RAM window as your program is simulated.  It's a good idea to do this every time you simulate the program.

©Peter Minns2003.

 

 

[Link to Practical Session 1]


  [back to top]


Updated 20.06.07 ML

Site Search

Powered by Google
Site Map