PIC

From Fixme.ch
Jump to: navigation, search

This page here is for those who'd like to use Microchip PIC µCs. As usual, linux support is bad, and there are quite a few quirks.

IDE

MPlabX

Microchip recently (~2010-10) released a linux version of their new IDE. It can be found at [A]

There seems to be problems with some versions of ICD2 not being supported by MPlabX, so I will not go further in the details.

Piklab

Piklab is an open-source IDE for PIC µCs. It works fairly well, although you MUST create a new project before trying to configure the toolchains (else Piklab will crash).

Debian-likes have a packages called piklab

Toolchains

These basically include compiler, linker, and so on. Which toolchain you chose will basically depend of the µC you chose.

dsPIC

Use MPlab's C30 compiler. It can also be found at [A].

Piklab

Provided you installed the toolchain in /opt, you must configure as follow:

Executable directory: /opt/microchip/mplabc30/v3.30c/bin/bin/
Header directory: /opt/microchip/mplabc30/v3.30c/support/dsPIC33F/h/
Linker script directory: /opt/microchip/mplabc30/v3.30c/support/dsPIC33F/gld/
Library directory: /opt/microchip/mplabc30/v3.30c/lib/

Be careful, as device-dependant includes have mixed-case filenames. So:

#include <p33fj128mc804.h>

must be replaced with

#include <p33FJ128MC804.h>

If (when) you get an error about missing __reset definition, some additional command line arguments must be specified [1]. Since I was not able to configure piklab accordingly, I created a bash script to circumvent the problem:

#!/bin/bash
exec /opt/microchip/mplabc30/v3.30c/bin/bin/pic30-coff-ld.bin --start-group -lpic30 -lc -lm --end-group $@

of course, you need to

mv pic30-coff-ld{,.bin}

you might want to do this with pic30-elf-ld as well, and make the scripts executables. With this, I was able to compile a very simple program.

External links