Getting Started With MPLAB - Ready

2y ago
10 Views
2 Downloads
468.70 KB
10 Pages
Last View : 11d ago
Last Download : 3m ago
Upload by : Olive Grimm
Transcription

Page 1 of 10Getting started with MPLAB(PIC assembler and simulator)for PIC12F508 assembly languageprogrammingENGR 4250Fall 2006Michael A. CovingtonKey idea behind MPLAB: You’re not just creating an .ASM file foryour program. You’re creating a project (MCP file), which tells thecomputer which ASM files are involved (there could be several) andother settings. MPLAB can also work with C and other programminglanguages.NOTE: If MPLAB won’t start and you get the message “AccessDenied,” it’s because you don’t have permission to write in C:\ProgramFiles\Microchip. MPLAB requires us to violate normal Windows securitypractice by allowing ordinary users to write in Program Files.Creating your program:Go to Project and choose Project Wizard.

Page 2 of 10Select the device (PIC12F508).Select Microchip MPASM Toolsuite.If there’s a red X showing anywhere, MPLAB needs to know where thetools are, namely C:\Program Files\Microchip\MPASM Suite. Don’t mixup MPASMWIN with MPASM.

Page 3 of 10Give your project a name and say where you’re going to put it.Next, Project Wizard offers to add some files to your project. We’regoing to skip this window and use a much better user interface to addfiles at the next step. So just click Next at this screen:Give final approval, and your project will be created:

Page 4 of 10Now you have an empty project with no files in it. You must createor add an .ASM file in order to have something assemble. We’ll get tothat. Here’s what an empty project looks like:As a first step, adding a linker script to your project is stronglyrecommended. This tells the MPASM suite to use a more modernmethod of generating your .HEX file which will get around an old 62-

Page 5 of 10character limit on path lengths. If you skip this step, you can stillassemble your file provided the full path to it(C:\Documents.\.\etc.) isn’t too long.Let’s add the linker script now. Right-click on Linker Scripts,navigate to C:\Program Files\Microchip\MPASM Suite\LKR, and pickthe file that matches your processor. Check “System” so MPLAB willknow you want to use the “canned” linker script without editing it.(An alternative is to use Windows to make a copy of 12f508.lkr intoyour project directory, then add the copy. That may be wiser in thelong run.)Now it’s time to create or add an .ASM file. Right-click on SourceFiles, navigate to your .ASM file, and add it. Or choose File, New,type in at least part of the file, save it, and then add it. When you’redone, your project will look like this:

Page 6 of 10Now you have a working environment with an editor for your file, andthe file is shown in the contents of the project. To open your .asm fileif it’s not already open in the editor, just double-click on it.Here is a very simple program you can type in:; Very simple PIC12F508 programprocessor 12F508include p12f508.inc configorgclrfIntRC OSC & WDT OFF0GPIO; all outputs : 0movlw b'11111110'tris GPIO; lowest bit of GPIO becomes an outputxbsfGPIO,0; bring GPIO bit 0 highgotox; endless loopendWith this open in the editor, here’s your project:

Page 7 of 10Save your program.Assemble it by pressing F10.When your program assembles successfully, you’ll get output like this:

Page 8 of 10Here’s what the messages mean:“myfirst.o is out of date” – Your program has changed since the lasttime it was assembled, so it’s going to be assembled now.“myfirst.cof is out of date” – Same thing. The .o file and then the .coffile and finally the .hex file are the products of assembly and linkage.(Linkage means putting together subroutines that were in separate.ASM files.)If there is an error message about the COD file, ignore it. COD filescan’t contain long paths (“C:\Documents and Settings\.\.\.”)above a certain length. If you are fastidious, you can go to Project,Build Options, MPLINK, and check Suppress COD File Generation.Simulate your programGo to Debugger, Select Tool, MPLAB SIM.Go to View, Special Function Registers, so you’ll be able to see theoutput port. (You can also view several other things.)Then run the program using the buttons at the top right:

Page 9 of 10(This picture is from simulation of a different program on a differentCPU than the preceding example.)

Page 10 of 10Program your PICConnect the PICSTART Plus to the serial port and power it up.Go to Programmer, Select Programmer, PICSTART Plus.Go to Programmer, Enable Programmer.(Ignore an error about the PICSTART Plus needing to be updated.)Go to Configuration and make sureSelect Device and Configuration Bits are correct.(They should agree with the config statement in the program andthe selections you made earlier, but please double-check.)Insert the PIC in the PICSTART Plus.Go to Programmer and program or verify your device.Insert the PIC in the breadboard and see if it works!When you finishBe sure to “Save Workspace” (under File) as well as saving yourassembly language program.

other settings. MPLAB can also work with C and other programming languages. NOTE: If MPLAB won’t start and you get the message “Access Denied,” it’s because you don’t have permission to write in C:\Program Files\Microchip. MPLAB requires us to violate normal Windows security pract

Related Documents:

Chapter 1: MPLAB IDE Preview – An overview of what MPLAB IDE is and how it works. Chapter 2: MPLAB IDE Installation – How to install MPLAB IDE on your computer. Chapter 3: Getting Started with MPLAB IDE – A Tutorial – How to begin using MPLAB IDE. Chapter 4: MPLAB IDE Projects Tuto

MPLAB X CCS C Compiler Tutorial How to install the CCS C Compiler inside MPLAB X Before the CCS C Compiler can be used inside MPLAB X, the CCS C MPLAB X Plug-in must be installed. This process can be done inside MPLAB X. 1. Launch MPLAB X. 2. From the MPLAB X menu, select Tools - Plugins 3.

MPLAB C18 C Compiler The layout of this document: –Installing MPLAB C18: A step-by-step guide through the installation process of MPLAB C18 Compiler. –Configuring MPLAB IDE: MPLAB IDE setup for use with MPLAB C18. Basics of MPLAB IDE configuration to run your Program

MPLAB SIM MPLAB ICE 2000 MPLAB ICD 2 MPLAB ICE 4000 MPLAB IDE Debugger The other debug engines are hardware devices, while MPLAB SIM is a software program, running on your PC. MPLAB SIM provides many of the same features as in-circuit emulators and in-circuit debuggers.

MPLAB X IDE The latest information on Microchip MPLAB X IDE, the Windows Integrated Development Environment for dev elopment systems tools. This list is focused on the MPLAB IDE, MPLAB ID E Project Manager, MPLAB Editor and MPLAB SIM simu

MPLAB Harmony provides a MPLAB Harmony Configurator (MHC) MPLAB X IDE plug-in that can be installed in MPLAB X IDE to help you create your own MPLAB Harmony applications. To create a new MPLAB

MPLAB Harmony provides a convenient MPLAB X IDE plug-in configuration utility, the MPLAB Harmony Configurator (MHC), which you can use to easily create MPLAB Harmony-based projects. This tutorial will show you how to use the MHC to quickly create your first MPLAB Harmony application using the following steps: Step 1: Create a New Project

Starting MPLAB SIM MPLAB Desktop You should already be familiar with MPLAB IDE before going through this seminar. You might want to watch the “Introduction to MPLAB” seminar first. The MPLAB IDE desktop has all the standard