8
Channel LED Chaser
for 16F628A
- Quick guide
to assembling firmware with MPLAB
This is a very quick guide to allow
you to edit the sequence data and then reassemble the code to get
the HEX file needed to program into the PIC microcontroller.
It's not a comprehensive guide to using the MPLAB IDE and it's not
intended to be...
- Download the LED Chaser source
code and unzip all the files to a working directory.
Tip: the MPASM assembler doesn't like directory path + file
name to be longer than 62 characters so avoid unzipping
into a directory in 'My Documents', instead create one off the
root of C:, for example c:\pic\chaser\
- Run the Microchip MPLAB IDE
application and open the .asm file and the sequence data file.
These are highlighted in the screen shot below. File names
may vary slightly with different firmware versions.
- The files with a .inc
extension are include files. They are named in the .asm file and
are read by the assembler during the Quickbuild, don't change or
delete them.
- From the Configure menu open
'Select Device'
- Select the PIC from the drop
down list as shown below.
- You will find both 16F628 and
16F628A in the list, select the correct type that you will be
using.
- You can create, edit and
change the sequences in the sequence data file. When
you've done, save the file before going to the next step.
Guide to sequence
data format
- Highlight the pwmc_mainxxx.asm
editing window.
- Next select Quickbuild from
the Project menu. The Quickbuild option will run the
Microchip MPASM assembler that creates the .HEX file from the
source .asm and .inc files.
- Note: if the Quickbuild
menu option doesn't show the name of the .asm file, you haven't
selected the window in the last step.
- Once the Quickbuild has
finished check the output window to make sure the build
succeeded. If you get the 'Build Succeeded' text at
the end you will find a .HEX file in the working directory with
the same name as the .asm file. e.g.
pwmc_main123.asm will generate a file named pwmc_main123.HEX if
the build is successful.
- If there are any errors
reported here, or the build fails you need to investigate and
fix them before programming the PIC. Be aware that if the
.HEX file already exists from a previous successful build and
the build subsequently fails, the .HEX file in the working
directory is the one from the last successful build.
(this is a tip worth remembering before wasting hours trying to
understand why the changes you make don't appear to work:-)
- After a successful build, if
you look in the working directory you will see a file with a
.lst extension. If you open this file in a text editor and
go to the very end of it you will see a memory usage map.
This is a quick way to see how much memory has been used and how
much there is left to add extra sequences into.
MEMORY USAGE
MAP ('X' = Used, '-' = Unused)
0000 : X---XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX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XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
0400 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
0440 : XXXXXXXXXXXXXXX- ---------------- ----------------
----------------
2000 : -------X-------- ---------------- ----------------
----------------
All other memory blocks unused.
Program Memory Words Used: 1100
Program Memory Words Free: 948
Errors : 0
Warnings : 0 reported, 0 suppressed
Messages : 0 reported, 3 suppressed
- The sequence data file that
will be used when the firmware is assembled is named in the
pwmc_mainxxx.asm file.
- You can have a number of
different sequence data files and specify the one you want to
use in the .asm file before assembling.
- In the example screen shot
below there are three different sequence data files. One
is used and the other two are commented out. When the code is
assembled it will use the pwmc_SeqData.inc file.
(In MPLAB any text on the line after the ';' semicolon is
treated as a comment)
|