The version 1.0.2 is out. It is mainly about adding the new supported chips from SDCC 3.2 and corrected a few minor bugs.

I really like to thanks Eduardo Casino and Volker Schilling-Kästle and the people from microchip forum (mainly on this thread)

Hope you all enjoy it.


The main objective of this project is to promote the use of free programming toolchains for anyone interested in creating stuff with PIC16 and PIC18. This lead me to start using SDCC and GPUtils. When Microchip first shipped MPLABX*, based on netbeans I thought it would be really great if we could join all three and distribute a complete IDE+Compiler+Programmer which can run on any operating system, at least on the three major ones (win, linux, mac). With the help from Microchip developers the SDCC toolchain plugin was developed.

So any doubts/problems/bugs on the plug-in can be sent to me (rmaalmeida @ gmail . com), I'll try to cover them ASAP. If you want to help improve the plug-in just enter in contact.

*It is possible to use SDCC and GPUTILS on MPLAB 8.XX, although it is a little buggy. I've a guide on how to setup MPLAB 8.XX and SDCC available in Portuguese. I'm translating it and will post when finished.

** Click on the images to get a full resolution version.


The toolchain needs 2 programs to be downloaded/installed ahead SDCC and GPUTIS.

SDCC is the compiler. It translates the C code to ASM code. The compiler can also generate code for other architectures besides PIC16 and PIC18, but it is not addressed in the plug-in. It is open for contributions.

The GPUTIS is a collection of GNU tools to link and generate machine code from the ASM files. We'll be using two tools from it: glink and gpasm.

SDCC can be obtained from and GPUtils from

The installation is pretty straight forward, just download the setup and run. They maintain versions for Win/Linux (SDCC/GPUtils), and Mac (SDCC only). But you can download the source code and "configure && make && make install" them. If installing in windows double chech if "Add C:Program Files\gputis\bin" (for gputils) and "Add C:Program Files\SDCC\bin" (for SDCC) are checked at the end of the installation. This is really important for them to communicate with MPLABX.

GPUtils Installation

After installing both tools, open the MPLABX go to Tools->Options->Embedded->Build Tools, and press "Scan for Build Tools", the MPLABX should be able to retrieve information from all the installed toolchains:

Scan for build Toolchains

Just make sure that the SDCC version is visible after the "SDCC Toolchain" entry. In the picture I was using 2.9.0. Otherwise go manually to set the "Base Directory". Remember that the base directory is the /bin/ folder inside the directory you choose to install the SDCC compiler not the GPUTILS. If the scan does not works, try uninstall SDCC and GPUtils and reinstalling them making sure to add their directories to the PATH.

If you're using the SDCC compiler from versions 3.0 onwards you need to check the "Use non free libraries" option. This is done after creating a new project go to File->Project Properties-> Conf:[default]->SDCC Toolchain->sdcc->Option categories->General:

Use non free libraries

Creating and compiling a new SDCC project with MPLABX:

This example was made using SDCC 2.9.0, GPUTILS 0.14.0 and MPLABX beta 7.0.

In order to create a new project go to: File->New Project-> Standalone Project:

New project - 1st step

Select the correct family and processor (SDCC only works with PIC16 and PIC18)

New Project - 2nd step

Select your programmer/debugger:

New project - 3rd step

Select the SDCC toolchain, make sure that there is a green circle before the SDCC name, otherwise you've selected a processor that is not compatible with SDCC.


Create the project in the desired location. Note that MPLABX will create a directory with ".X" extension automatically for the project. Another point to pay attention is encoding, mainly if you're going to use non ASCII characters as accents or other non-English letters. Check other tools to assure which one is better for you. ISO-8859-1 and UTF8 are the most common.

New project - 5th step

Lets add some pre-made files: right click on the "Source Files" folder and choose New->Other

New source file

Select Microchip Embedded->SDCC Compiler->main.c to create an example main file

New source file

You'll get the following code:

Main file example

Don't worry about the warnings MPLABX give on the "interrupt 1" and "interrupt 2" keywords. This is the way SDCC allocate the functions on the interrupt table and it is not 100% integrated with the IDE.

Now you can use the common headers from SDCC (for more information go to SDCC manual ( to compile your program:

Example source code

If you open the listing file, you can see the generated code. See that the TRISD is correctly cleared at address 0x95 and PORTD gets the 0xAA value at address 0x83 (the compiler has already set the bank to the SFR memory position).

Example asm file

Rodrigo Almeida,
25 de jan de 2013 16:20