Write programs for PICs in C using SDCC, a simple text editor and the command line on Linux

From Curuxa

If you like to write and compile your PIC programs in C on Linux using the most basic tools, these are the instructions:

System requirements

  • A working Linux installation
  • Text editor of your choice
  • SDCC
  • gputils


  1. Write your program in C-language using SDCC syntax. See its documentation. Each Main Board and Module has some sample code you can use
  2. Save it, for example, as MyProgram.c
  3. On the command line, cd into the directory MyProgram.c was stored
  4. Compile it using the following command. Replace p16fxxx by the PIC you are using
sdcc -mpic14 -p16fxxx MyProgram.c

Now you've got a .hex file you can program/burn into the microcontroller.

Sample video

We open a source code from the console (an example for making LEDs blink), compile it, burn it into the microcontroller, execute the program, then modify the source code to make the LEDs blink more slowly, compile it again, burn the new program, and execute it.