CPIK Project Page


CPIK (the C compiler for PIC18 devices) is now 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.

Roadmap:

  • V0.7 Support bit fields
  • V0.8 Libraries
  • V0.9 Optimization

See here the PDF documentation for version 0.6.0.

Contact: Drop me an email here


What is new:

CPIK 0.6.0 with support for IEEE floating-point calculation is available !

Jean-Marie Leroy sent me a new version of his flowchart-to-C code generator for cpik. This program is now written in Python (the previous version in C++ is not available anymore). See various zip archives below. For any question, ask Jean-Marie directly.

Josef Pavlik is a new contributor to the cpik project who has developed a lot of new features for version 0.5.3. Thanks to Josef, this version is a real improvement over the previous one.


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.

-in version 0.6.0 (DMR)

  • 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 printf and 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 va_xxx macros.
  • 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.
  • And more..
Release 2: cpik-0.6.0-2.tar.gz fixes a distribution issue (wrong stdio.h header).

-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,
  • And more..

-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

CPIK tutorial: 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.

Distribution:

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.1.0 which have support for cpik C projects and PicKit2 USB programmer.

 CPIK 0.6.0 source code (FP support and many new features)
Tarball (source code and all needed files + install procedure) cpik-0.6.0-2.tar.gz
 CPIK 0.5.3 source code (many new features)
Tarball (source code and all needed files + install procedure) cpik-0.5.3-5.tar.gz
 inc2h utility (convert Microchip's ".inc" files to cpik ".h" files)
Tarball (source code) inc2h-src.tar.gz
 piq18_algocode : flowchart-to-C code generator by Jean-Marie Leroy (in python)
Zip (Python source code) piq18-algocode_1.1.zip
Zip (Documentations in pdf -read them first-) piq18-algocode_1.1_doc.zip
Zip (Addons for developers) piq18_components.zip
Zip (New plugins) piq18_components_Comm.zip
Zip (Other addons) piq18Traducers.zip
 Precompiled cpik 0.5.3 and gpasm for Windows (use it for piq18_algocode - Windows)
Zip (executables and libs) freePic.zip

INSTALLATION OF PRECOMPILED BINARY FROM TARBALL (obsolete)

  • Unpack the archive
    tar xzvf cpik-[version]-bin.tar.gz
    
  • Go to cpik directory
    cd cpik[version]
    
  • Become root
    su
    Password: [root passwd]
    
  • Run the installation script
    ./cpik-install
  • Return to user mode
    exit
  • Read the documentation located in the doc directory of binary distribution.
    A tutorial is also available at the same location.

  • Run PiKdev and configure it for cpik (the only thing to do is to configure the path to cpik : /usr/bin/cpik), then create a new C project : enjoy!

INSTALLATION OF PRECOMPILED BINARY FROM DEBIAN ARCHIVE (obsolete)
  • Use dpkg tool
    su
    Password: [root passwd]
    dpkg -i cpik[version].deb
    
  • or kpackage graphic tool (from KDE suite)
 

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.
then:

  • Unpack the archive
    tar xzvf cpik-[version].tar.gz
    
  • Go to cpik directory
    cd cpik-[version]
    
  • 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
    make
  • become root
    su
    Password: [root passwd]
    
  • install the executable in the proper directory
    make install
    
  • Return to user mode
    exit