Home
People
Publications
Events
Teaching
Projects
Resources
Contact
Community
Blog







Tutorials
Software
Docs

:: Research Group Embedded Interaction :: Media Informatics :: Ludwig-Maximilians-University Munich


Particle Programming with MPLAB

MPLAB is Microchips Integrated Development Environment. It can be download directly from Microchips MLAPB Site.

If you are using CCS' C-Compiler, make sure to run their MPLAB integration tool, otherwise the PIC Compiler will not work. The MPLAB integration tool for MPLAB version 6.xx will work for MPLAB v. 7.00.

After the installation you will find the highlighted tool suite (under Project select Set Language Tool Locations). Make sure to use this one. Do not use CCS C Compiler or you will get 'BUILD FAILED' after compiling and downloading the HEX file will not work.)

Before starting your own projects, make sure to configure MPLAB to not use a one-to-one-workspace setting. You can switch on this setting under Configure, Settings.

You also have to configure the configuration bits for the processor. The configuration can be done under Configure, Configuration Bits. See the following image (click on the image for a larger version) for the settings required for the Smart-Its or Particles.

After the workspaces and device parameters are set correctly, make a new workspace by using the Project Wizard (Project, Project Wizard). For Smart-Its programming, the chip is the PIC18F452, for Particle programming, the chip is the PIC18F6720.

Save you workspace now to prevent damage to your workspace because of MPLABs stability problems.

Now configure your programmer. We do use a MPLAB ICD2 (ICD = in circuit programmer) programmer. Select your programmer by clicking on Programmer, Select Programmer and then choosing your programmer.

Go to the menu Programmer and chose Settings.

Make sure to power the Particles from the MPLAB ICD2. When using Smart-Its, you need not to power the target chip.

Let the programmer automatically chose which memory ranges to write.

Now you can run the self test in the status tab.

Save your MPLAB workspace to make sure the programmer is selected when you open the workspace the next time.

 

MPLAB Programming

You can now add files to your project by right-clicking on Source Files in your Workspace (window with the title <muc.mcw>) and selecting Add Files... . In our example, we named the workspace muc.mcw and the project muc.mcp.

Click right on the <muc.mcp> and select Build Options. You now should add your own compile settings, e.g. additional include directories.

You can now click on the compile symbol and compile your source code. If your code contains any includes (e.g. for the PIC), these files are added automatically to the section Header Files in your project (here: muc.mcp). The output window there should read BUILD SUCCEEDED, preceded by warnings that may appear. Click on the image for a larger image.

Now you can program your device using the appropriate buttons of the MPLAB IDE. Click on the left icon (see image below) for downloading the code to the target

By clicking on the rising flank to start the program.

Programming HEX Files with MPLAB

To directly download hex files into a device, do the following:

  • Close all open workspaces of MPLAB
  • Configure your programmer
  • In MPLAB, click on 'File' and select 'Import'
  • It seems that nothing is happening, but the hex file is imported
  • Click on the programmer icon. The output window should state that the device is programmed

MPLAB Problems and Known Bugs

If you receive the error message 'The format of the file XYZ.COD can not be read or written because its extension was not recognized' (see the picture below), then add '+DF' to the compiler option string.

We only received this error on a Windows 2003 Server machine and could not reproduce it on any other operating system.

The format of the file XYZ.COD can not be read or written because its extension was not recognized

If you receive the error message 'Warning! MPLAB IDE does not currently support this OS.' on a Windows 2003 Machine, ignore it.

Attention: if you receive any warning or error message when compiling code with MPLAB, e.g. the message above on the .COD file, then the programming of the PICs with any programmer does not work! You will notice then that MPLAB does not write the programming region (0x00 - 0x...) in the output window and programming will be faster.

 

Please see also our other how-to pages:

How-Tos