| Tools - Software | ||
| Links Mentioned MPLAB MPLAB ICD |
![]() While you are waiting for your parts, you can download some software and simulate PIC programming right away. Microchip lets you download their very powerful MPLAB software free on the Internet. The program allows you to create a project, enter source code, assemble it, and even simulate executing it. If you have a PICStart programmer (or a compatible programmer) you can burn the program right from MPLAB into the chip. If you have an in circuit emulator (like the MPLAB ICD) you can emulate your program in the same MPLAB software. Not a bad deal for free! Some of the screen shots in this section assume you are using a PIC16F84 and others show 16F873. However, if you are using the APP-II, you'll use 16F873 everywhere that 16F84 appears (and vice versa if you are using the F84). MPLAB works the same either way.
MPLAB changes from time to time, so you should download the latest version from MIcrochip. Be sure to work through the tutorial provided by Microchip. You can either work through the steps below or view the interactive tutorial (requires Java). Here's the basic steps you'd take to write your first program: 1. Select the Project | New Project menu. 2. Enter a name for your project (for example, tutor.pjt). 3. You'll see this dialog:
4. If your dialog doesn't look like the one above, change the Development Mode and Language Tool Suite to match. Obviously, if you are using the PIC16F84, you'd choose that instead of PIC16F873. 5. Press the Add Node button. When prompted for a file name, type "tutor.asm" and press OK. You may have to direct MPLAB to the project directory (why it can't do this itself is a mystery). If you try to use a file outside the project directory, you'll get an error and you can try again. 6. Optional: Click on tutor [.hex] and click Node Properties. Turn off Case Sensitivity. I personally prefer not to worry about case when programming. 6. Dismiss the Edit Project Dialog by pressing OK. 7. Select File | New to create a new source file. 8. Enter the following program (change references to 16F873 to 16F84 if using that processor):
9. Select File | Save and save the file as "tutor.asm". 10. Select Project | Make. 11. You should get the following message:
If you don't, you've put something in wrong. Check your work and try again. Congratulations! You just wrote and built a PIC program! We'll look at it in detail in future frames. For now, just realize that you have transformed an ASM file (a program) into a HEX file (a binary file that you can load into the PIC). MPLAB prefers you to use a project, which may contain different files and options. In this case, we probably didn't need the project, but it will come in handy later. If you want, try experimenting with the MPSim simulator at this point. To get started, select the program source code window and press F7 to step through the program one step at a time. You can see the registers and memory by selecting different display windows from the Window menu. |