"Easy PIC'n" and "Easy Microcontrol'n" version 4.0 were based on MPLAB versions up to 5.70. With version 4.1 of "Easy Microcontrol'n", we changed to MPLAB 7.xx because we expected that MPLAB 5.70 would go away. Now it is gone.
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
changed on-screen
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 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.
Text Editor
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).
Click "Save".
Project
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).
Click "OK".
Click "Next".
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.
Assembler
Open your assembly source file (File>Open). Find and highlight "PICT1.ASM".
Click "open".
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
Project>New.
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).
Click "OK".
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".
Click "OK".
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.
Window Menu
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>.
Line Numbers 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.
Click Ok.
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.
MPLAB
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 "Apply".
Click on the "Memory Ranges" tab.
Check "Program memory".
Check "Configuration bits".
Uncheck "ID location".
Uncheck "EEPROM data". Click "Apply".
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).
Programmer>Enable Programmer.
Programmer>Program.
A Configuration Warning box will appear.
Click "Yes".
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
Programmer>Read.
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
--------------------------------
Status 0 0 0 0 1 1 1 1
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.

If you have questions, contact us by eMail at sqone@pacific.net, telephone (208) 664-4115, fax (208) 772-8236. Dave & Wanda
[Home]
[MPLAB]
[Order]
[Contact US ]
[TOP OF PAGE]
© Copyright 1996-2007 Square 1
Electronics This page last updated March 1, 2007
;*******************************************************************
; simple.txt
; Font --- courier new, Regular, 8
; This code assembles without any errors, messages, or warnings.
; Just rename to simple.asm, then run MPASMWIN.EXE to get the hex file.
; Written by David WardenDurkee
; http://www.vvm.com/~darkwing/home.html
; Semicolons are comments
; 20 Jan 2002
; PORT A all outputs (leds)
; PORT B all inputs (switches)
; 12 Mhz crystal
; This program turns on and off PORT A LEDs about twice per second
;*******************************************************************
LIST P=16F84;f=inhx8m
#include "P16F84.inc" ;WORKS
;#include <P16F84.inc> ;WORKS
__CONFIG 3FF2 ; configure programmer directive SEE PAGE 38 OF DATASHEET(0011 1111 1111 0011)
; ; HS - high speed ocsillator, code protect off
; ; watch-dog timer disabled, powerup timers enabled
C1 EQU 0C
C2 EQU 0D
C3 EQU 0E
ORG 0 ; ORG needed here--do not move
INITIALIZATION
MOVLW .0 ; 0000 0000 binary (0x00 in hex) binary 0 is output, binary 1 is input
BSF STATUS,RP0 ; Change us to BANK 1, we want to set I/O of PORT A.
; ; When in BANK 1 we set the direction (I/O) instead of the output level.
MOVWF 0X05 ; 0x05 gives no error when compiled ; 0X85 or TRISA == What the argument should be for BANK1
BCF STATUS,RP0 ; BANK 0
MOVLW .31 ; 1 1111 binary or (0x1F in hexidecimal)
MOVWF PORTA ; set PORT A levels all high, when in BANK 0 we set the output instead of the direction (I/O)
MOVLW .255 ; 1111 1111 binary (0xFF)
BSF STATUS,RP0 ; BANK 1 TO SET I/O
MOVWF 0X06 ; 0X86 ; TRISB
BCF 0X01,7 ; 0X81,7; OPTION_REG,7 ; 0== internal pullups enabled only for INPUTS
BCF STATUS,RP0 ; BANK 0
GOTO MAINLOOP
;---------------------------SUB-ROUTINES------------------------------------
DELAY
MOVLW .40 ; .xx is decimal number, 0xXX is hexidecimal
MOVWF C1
AA MOVLW .80
MOVWF C2
BB MOVLW .77
MOVWF C3
CC DECFSZ C3,F
GOTO CC
DECFSZ C2,F
GOTO BB
DECFSZ C1,F
GOTO AA
RETURN
;***************************************************************************************************
MAINLOOP
MOVLW .31 ; This decimal number is ( 1 1111 )in binary.
MOVWF PORTA
NOP
NOP
CALL DELAY
MOVLW .0
MOVWF PORTA
NOP
CALL DELAY
GOTO MAINLOOP
END
|
|