In the past, we have recommended that readers of “Easy PIC’n” and “Easy Microcontrol’n” version 4.0 use MPLAB version 5.70 when getting started because, in our opinion, it is easier to use than the newer MPLAB 6.xx, now 7.xx. With version 4.1 of “Easy Microcontrol’n”, we changed to MPLAB 7.xx because we expect that MPLAB 5.70 will go away.|
At this writing, MPLAB 5.70.40 is still available on microchip’s web site. Instructions for finding it appear below.
For “Easy PIC’n” and “Easy Microcontrol’n” version 4.0 readers who want to use MPLAB 7.xx, an overview is presented below.
MPLAB 7.xx was initially developed for the high-end 18 series devices and has been upgraded backwards to support less sophisticated devices. Device support has been added for all 12 and 16 series devices. Both MPLAB versions are currently available. MPLAB 7.xx has a LOT of differences with respect to 5.xx.
MPLAB 5.xx MPLAB 7.xx
Select tool, then device Select device, then tool
Use "modify" dialog boxes Edit values directly
to edit values in text windows
Has status boxes Has text windows
Configuration word Configuration word
ignored for ICD used for ICD 2, but
selections can be
They are quite different in look and feel.
If you purchase an ICD 2 and want it to work with the 14-bit core devices that have in-circuit debugging capability (F870, F818, etc.), you will need to use 7.xx.
MPLAB 7.00 kick-start instructions follow for your use when the need arises. These instructions replace pages 40 through 44 in “Easy Microcontrol’n” Version 4.0 (or pages 37 through 42 in “Easy PIC’n”).
MPLAB – FINDING MPLAB V. 5.70
MPLAB is available at no cost from Microchip’s web site at http://www.microchip.com.
To obtain MPLAB v.5.70.40,
Click on “MPLAB IDE” on the home page
Scroll down to “MPLAB IDE Archives” at the end of the list and click on it
In the 16-bit Windows column, click on “5.70.40.”
MPLAB V. 7.00 OVERVIEW – GETTING STARTED
MPLAB 7.xx is easy to find on Microchip’s website.
MPLAB v7.00 is a large program with lots of whiz-bang features, so it would take a whole book to describe it completely. As with most computer programs these days, you will only need to know a little bit to get started using it. That’s next.
Microchip continually releases new versions of MPLAB. The following instructions will help get you started if you are using v7.00 or later. MPLAB v7.00 is the current version as this is being written.
USING MPLAB – GETTING STARTED
Using MPLAB may seem a bit strange at first because of the terminology. It will soon become familiar and will be easy to use. Having the text editor, MPASM assembler, and PICSTART Plus (if you use it) software open/accessible simultaneously and to be able to switch back and forth quickly at will is nice.
We will assume the use of Windows 98 for the following example.
We will assume that the assembly source files you create will be stored in the same folder as MPLAB 7.00.
Open MPLAB by double-clicking the Microchip MPLAB icon. The MPLAB window will appear with a blank “document” at the left side of the screen labeled “Untitled Workspace”. Close Untitled Workspace. MPLAB is ready for use.
A text editor is built into MPLAB.
In the file menu, click “New”. A window labeled “Untitled” will appear.
Now you can type in some sample code. We will use PICT1.ASM from Easy Microcontrol’n, page 28. When you are finished, save the file (File>Save).
In the “Save As” dialog box, edit the file name. Use the .ASM extension (PICT1.ASM).
Save as type “.asm”. Save in the same folder as MPLAB 7.00 (or the more recent version 7.xx you may be using).
A principal new term you will need to know to use MPLAB is “project”. A project is one or more files grouped together and used to make code for a PIC microcontroller. The best way to learn this stuff is by doing a simple example.
Click “Project” in the menu bar. Click “Project Wizard” in the drop-down list (Project>Project Wizard).
Welcome! Click “Next”.
In the Project Wizard Step 1 dialog box:
Select the PIC16F84A. Click “Next”.
In the Project Wizard Step 2 dialog box:
Use the default toolsuite (MPASM). Click “Next”.
In the Project Wizard Step 3 dialog box:
Type the project name.
“PICT1” is your project name and “PJT” means project.
Select a directory for the new project by clicking on the “Browse” button and working your way to the MPLAB 7.00 folder (or the more recent version 7.xx you may be using).
The Project Wizard Step 4 dialog box will appear. Scroll down and find the file name “PICT1.ASM”. Highlight it.
Click “Add”. This associates the assembly source code file with the project.
Click “Next”. The Project Wizard Summary dialog box will appear.
Click “Finish”. The PICT1.PJT.mcw window will appear. You cannot close it.
Open your assembly source file (File>Open). Find and highlight “PICT1.ASM”.
To assemble your source code (with your project open and the source code on screen), click “Make Project” under the project menu (Project>Make). The terminology is a bit strange. Clicking “Make Project” causes the source code to be assembled by MPASM, the assembler which is built into MPLAB. The result is a file with your file name and the extension .HEX (dot hex file).
The assembly process ends with the Build window being displayed. If your code assembles properly, the message “Build Succeeded” will appear. If there are errors or warnings, each error or warning in the list will have a source code line number associated with it. If you open the source code window’s drop down list, you will see that the last item on the list is “Toggle line numbers”. Clicking on this will cause line numbers to appear in the left margin of the source code. Clicking again causes the line numbers to go away.
Ignore the warning message associated with use of the TRIS instruction.
Close the Build window.
Last, save your project via Project>Save Project. Then close your project via Project>Close Project. Close MPLAB.
MORE MPLAB OPERATIONS
As you gain more experience, you may wish to perform certain tasks without using the Project Wizard or to perform some other tasks.
Create a New Project
The New Project dialog box appears.
Type the project name.
“PICT1” is your project name and “PJT” means project.
Select a directory for the new project by clicking on the”Browse” button and workingyour way to the MPLAB 7.00 folder (or the more recent version 7.xx you may be using).
Select Device Type
Click “Configure” in the menu bar.
Click “Select Device” in the drop-down list (Configure>Select Device).
In the Select Device dialog box:
Select Device: “PIC16F84A”.
The Select Device dialog box will close.
Add a File to a Project
Project>Add Files to Project.
Remove a File From a Project
Project>Remove File From Project.
To View And Print A .LST File
In the file menu, select “View”. A dialog box will appear. Type in the name of the file you would like to view and print (example: PICT1.LST). Click “OK”. The file will appear on screen. To print the file, select “Print” in the file menu.
To Delete A Project
Delete the project files using My Computer. It is the only way it can be done.
Status boxes do not pop up automatically with MPLAB version 7.00. It is necessary to select the window you want to view at any point in time by selecting Window>whatever. If you want to know the status of something MPLAB is (hopefully) doing for you, use Window>.
Error messages generated on completion of assembly refer to source code line numbers. Line numbers may be displayed or not as you choose. To display line numbers, press the right mouse button with the .asm file of interest open. A list will appear.
Click on Properties.
The Editor Options dialog box will appear.Click on the Editor tab. Check line numbers. Click on Apply. Close the Editor Options dialog box.
If you no longer wish to display line numbers, go through the procedure again and uncheck line numbers.
Tab Size (Spacing)
To change tab size (spacing), press the right mouse button with the .asm file of interest open. A list will appear.Click on Properties.The Editor Options dialog box will appear. Click on the Tabs tab. You will see tab spacing expressed as a number of characters. Type in your preferred number (I like 8). Click on Apply. Close the Editor Options dialog box.
Assembly Source Color Options
With the .asm file of interest open, highlight some text. Press the right mouse button . A list will appear.
Click on Properties.
The Editor Options dialog box will appear.
Click on the Text tab. Click on Choose colors.The Editor Color Customization dialog box appears. Click on Foreground Color. Color Selection matrix appears. Click on color of choice (try dark blue). Click OK.
The Editor Color Customization dialog box reappears.
The Editor Options dialog box reappears.Click Apply. Close the Editor Options dialog box.
PROGRAMMING A DEVICE
By now you have had an opportunity to assemble the source code file PICT1.ASM and are ready to proceed with programming the .HEX file created by MPASM (the assembler included in MPLAB) into a PIC16F84A device.
The “make project” process in MPLAB creates a .HEX file (PICT1.HEX in this case). If you have a PICSTART Plus, the device programming instructions follow. If you have another programmer, you may need to close the MPLAB program and open the driver software for the device programmer. The driver software and the .HEX file should be in the same directory. Follow the device programmer manufacturer’s instructions.
USING PICSTART PLUS
Begin by opening your existing project in MPLAB. Choose “Project Open” in the project menu followed by finding your way to the MPLAB 7.00 folder and selecting your project by name (PICT1.PJT). Choose “Open” in the file menu and select “PICT1.ASM”.
To Enable PICSTART Plus
Click on “Programmer” in menu bar.
Click “Select Programmer” on drop down list followed by clicking on
“PICSTART Plus” (Programmer>Select Programmer>PICSTART Plus).
Click on “Programmer” in the menu bar.
Click on “Settings” in the drop-down list (Programmer>Settings).
Click on the “Communications” tab.
Select the comm port you wish to use for the programmer.
Click on the “Memory Ranges” tab.
Check “Program memory”.
Check “Configuration bits”.
Uncheck “ID location”.
Uncheck “EEPROM data”.
Close the programmer dialog box.
To Program A Device
Power-up the PICSTART Plus.
Insert the PIC16F84A in the socket (be careful about orienting the device correctly
in the socket).
A Configuration Warning box will appear.
Programmer status will be displayed in bold text in a box near the top of the screen.
On completion, the programmer status should be:
Pass:1 Fail:0 Total:1
To Read A Device
To Erase A Flash Device
Programmer>Erase Flash Device.
THE BIG TEST!
Insert the programmed PIC16F84A into the socket on your test board (power off!). Power up the test board. The LEDs connected to port B should be off/on as follows:
Bit 7 6 5 4 3 2 1 0
Controlling LEDs is a BIG DEAL at this point! You now know how to use the computer, text editor, assembler, device programmer and program a microcontroller. Wow! Time to celebrate I’d say.
Status 0 0 0 0 1 1 1 1
If you have questions, contact us by eMail at [email protected], telephone (208) 664-4115, fax (208) 772-8236. Dave & Wanda
[Contact US ]
[TOP OF PAGE]
� Copyright 1996-2004 Square 1
This page last updated June 11, 2005