CPIK (the C compiler for PIC18 devices) is released under the GPL licence.
CPIK is an easy to use, near ANSI C compiler which is fully integrated
with PikDev. This project is still in progress but near to be finished and
the current version is perfectly usable.
(from Pikdev or from a command-line interpreter).
Contributors for this project are Welcome - please read the documentation
for details about how to contribute.
- V0.8 Libraries
- V0.9 Optimizations
See here the PDF documentation for version 0.7.2.
See here the installation procedure..
Contact: Drop me an email here
What is new:
1/3/2013 : CPIK 0.7.2 with support for new #pragma config is available.
18/3/2013 : Bug fix in the support of arrays of pointers to functions. Please upgrade!
10/4/2013 : Bug fix in the support of unions. Please upgrade!
9/6/2013 : Minor bug fix in run-time library, for the support of devices that do not use the EEPGD and CFGS bits.
-in version 0.7.2-1 to 0.7.2-4 (Stéphane Hessel)
Support for CONFIG (instead of _CONFIG) asm directive, that is specific to PIC18 devices.
A new #pragma config is implemented and fully compatible with the equivalent pragma of Microchip C compiler. The new pragma is supported by PiKdev V1.4.0.
New device headers for all devices that are currently supported by gputils 1.0.0. Devices with SFR that cannot be addressed in access bank are detected and supported. A new version of the inc2h utility has been developed for that purpose.
Bug fix: Because of a missing pair of parenthesis, the code generated for some access to struct members was wrong. Thank you to Jon Hilt for the bug report and fix.
Bug fix: Wrong support of arrays of pointers to functions. Thank you to Santiago Berca
for the bug report (issue fixed in version 0.7.2-2).
Updated headers and lkr files synced with gputils 1.1.0 (version 0.7.2-2).
cpik is now provided with an html version of the documentation that can be directly browsed from
PiKdev 1.4.0 (version 0.7.2-2).
Bug fix: Broken support of union. Thank you to Santiago Berca
for the bug report (issue fixed in version 0.7.2-3).
Minor fix in the HTML version of the documentation (version 0.7.2-3).
Minor fix in run time library (rtl.slb) and rom.h files (version 0.7.2-4).
Thank you to Cedric Debarge who have pointed out the problem.
-in version 0.7.1 (Lison)
Full support for bit fields.
Bit fields are now supported in the standard way.
- New headers files.
A new header file is now provided for each pic18 device.
These headers describe each device register as a bit field based structure.
They are compatible with Microchip's headers.
New inc2h-v2 utility.
This is a new version of the previous inc2h that is designed to build the "new style" headers files from
Microchip's .inc files.
Support for the const keyword.
const is now supported as specified by the ANSI standard. Because the compiler is now
strict about constness, old codes may have to be fixed.
- Explicit bit-fields.
This handy feature is an extension from the standard
that allows to slice any 8 bit variable in bit fields.
-in version 0.6.0 (DMR)
I would like to dedicate this version of cpik, to the memory of
Dennis M. Richie who died at the
beginning of october.
Dennis was the main inventor of the C programming language and for this reason (and his work on Unix) he has been a very important contributor to the modern computing science. I think he did a really good job whose impact is underestimated by most people.
Thank you Dennis, for this language that is so simple and so versatile.
I liked it at the first contact, and I continue to like it many years later.
Release 2: cpik-0.6.0-2.tar.gz fixes a distribution issue (in stdio.h header).
Full support for 32 bit floating point arithmetic.
This implementation is compliant with the IEEE-754 standard on floating point representation.
The run-time support is directly written in assembly language, so it is likely to be fast.
- Support for IO on floating point data. The
scanf functions have been updated for this purpose and new format specifications (%e %E and %f) are available. Several other functions are available to perform IO on FP data.
- Math library
This implementation of the math library is written in C and provides 22 usual functions for floating point calculation (trigonometric, exponential and logarithmic).
- Standard library
This is a first implementation of
stdlib that contains 10 usual functions.
- Functions with variable argument-list
This a fully compliant implementation of the ANSI standard about functions with variable argument lists, using the «...» syntax.
The standard header (
stdarg.h) provides the necessary
- errno support
The unix low-level mechanism for reporting errors during math or IO operations is supported, and the standard
errno.h header is provided.
- New -D command-line option.
Several optimisations and minor bug fixes
Updated documentation, including a section about installation.
-in version 0.5.3 (Marie Jeanne Gabrielle)
Bug fixes in code and run-time library,
Run-time library improvements,
New pin.h header for easy manipulation of I/O ports thru symbolic names,
Improved LCD library with pin configuration from C code,
Dead code elimination in the case of loops or test with constant conditions,
Optimisation of static data initialization, using the program sections concept,
Post-compilation branch optimizer that generally reduces the code size by 10%,
Implementation of the enum declarator,
Implementation of the switch instruction: this implementation is
efficient and provides a near constant-time case selection,
Support for data located in ROM, with different access mechanisms,
-in version 0.5.2 (Ferrara)
- Bug fix in ++ and -- operators please upgrade !
- The inc2h utility which makes cpik processor-specific headers from Microchip's ".inc" files is now available (source code only).
-in version 0.5.1 (Lisboa)
- Bug fix in constant folding in operator ?:
- Bug fix in pointer arithmetic with array operands please upgrade !
Thank you to Jeroen Demeyer for these bug reports
-in version 0.5.0 (Sienna)
- Full support for 32 bit signed and unsigned integers
- Rewritten support for side-effect operators such as +=, *=, etc.
-in version 0.4.1 (release 1 & 2) (Alain Bashung)
- Bug fix in return statement: please upgrade !
- Bug fix when passing arrays as function parameters
- New tutorial about LCD display support and A/D conversion
- Totally rewritten support for static entities initialization:
initialization of static structs and unions is now supported, initializer expressions containing constant symbolic data are supported
- Bug fix when compiling a malformed expression (r 2) please upgrade !
- Bug fix in sizeof operator when applied to undeclared variable (r 2)
- Array size specified by a constant expression (ie: 1+2*3) is now supported (r 2)
-in version 0.4.0 (Barcelona)
- ANSI compliant support for struct and union
- Many code optimizer improvements
- Comes with a simple tutorial dedicated to beginners
The tutorial is now provided as a separate PDF file .
It includes schematics and C source code.
This code can be downloaded separatly as a compressed archive
I strongly encourage people who intend to switch to PIC18 and/or C language
to read this tutorial. The PIC18 devices represent a huge improvement compared to
their 16F counterpart, and are not really much more expensive.
The C language is flexible and powerful, so it is a pity that people continue to write assembly code although this is generally not necessary.
Since version 0.5.3, cpik is only distributed from a tarball, because I don't have enough time
to make the other packages. Anyway, cpik is very easy to build and install, with Qt's qmake utility. Please see the bottom of this page for details.
Don't forget to download and install PiKdev version 1.4.x which
have full support for my cpik compiler.
| CPIK 0.7.2-4 source code (#pragma config support/bug fixes)
|Tarball (source code and all needed files + installation procedure)
| inc2h-v3 (support for silly SFRs)
|Tarball (source code and all needed files + install procedure)
| CPIK 0.7.1 source code (bit field support)
|Tarball (source code and all needed files + install procedure)
| inc2h-v2 utility (convert Microchip's ".inc" files to cpik ".h" files)
|Tarball (source code)
BUILD/INSTALL FROM SOURCE CODE WITH QMAKE
You must install the Qt development tool from Qt/Nokia. Free download
[ here ].
Obviously, a C++
compiler such as GNU's g++ must also be installed in your machine.
Unpack the archive
tar xzvf cpik-[version].tar.gz
- Go to cpik directory
Generate the Makefile (you need the qmake utility, from the Qt toolkit)
qmake -o Makefile cpik[version].pro (version should be 04x for v0.4.x)
- Build the application
- become root
Password: [root passwd]
- install the executable in the proper directory
- Return to user mode