Let's Make Robots!

MPLAB IDE - Template files (Part 2)

Makes an easy start to your pic project

Template files

Continuing from here

In the project wizard you will have selected an include file which holds all the definitions of pins and registers and a template for adding code to. These files are in the mpasm suite folder and mpasm suite/template folder. You can view them with any text editor but I use programmers notepad or notepad++ for this so that you get syntax colouring.


The include file defines the registers by the names you find in the datasheet. You can see by using the equate directive they are just substituting letters for numbers (which makes it easier for us to remember)

In the assembly file template below I have marked the sections and given a description of their purpose.
The syntax highlighting and style used helps make the code more readable.
Comments are in green and everytime the compiler comes across the ; symbol it knows the following text is a comment and not a label or instruction
Labels are in purple
Directives used by the compiler are in blue
Instructions are in black
Numerals and addresses are in a couple of different colours depending on radix(binary,decimal,hex)

After you get some coding under your belt and you've done a few projects you can make your own custom template file that you pick each time you create a new project. You could have multiple template files made and select the most appropriate for the current project.
You won't always use the EEPROM so why have to delete that section everytime you select the standard template. Just make a copy of the standard template and modify it till your hearts content.

Next part is here