Installing Microchip XC16 in CrunchBang Linux

XC16 is Microchip’s C compiler for the 16-bit dsPIC microcontrollers (PIC24, dsPIC30F, dsPIC33). I sometimes need to use it when I’m working in a live session in CrunchBang Linux.

First download the Linux installer for XC16

Then change directory into the downloads folder (/home/crunchbang/downloads/ in my case) and extract the installer from the tar archive:

cd downloads
tar xvf

Now, log in as root, install some dependencies, and run the installer:

sudo su
apt-get update
apt-get install lib32z1

You will be asked to agree to a software license and to answer a few questions on installation options. The default options are mostly acceptable, but make sure you reject the pay options and time-limited premium license. The free time-unlimited version should be adequate for most purposes.

By default the compiler is installed in /opt/microchip/xc16/

To compile a program, here’s an example command line:

/opt/microchip/xc16/v1.21/bin/xc16-gcc main.c -mcpu=30F4011 -Wl,--script=p30F4011.gld

That produces a file called a.out. To convert the compiled program to hex format (i.e. “a.hex”), use the bin2hex tool, as follows:

/opt/microchip/xc16/v1.21/bin/xc16-bin2hex a.out
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s