Friday, December 19, 2014

It could be something...

At the article's date, MPLAB XC8 compiler is at 1.33 version and shockingly, it scores smaller code sizes in the free version than the older and unsupported MPLAB C18 in his commercial version.  Regarding compiling bootloaders, C18 still remain the only alternative between the two, but anything else can be successfully compiled with XC8.

Well, "anything else" means all I have tested so far, in the form of a common code (the code can be compiled without modifications by both compilers) for custom libraries and projects and that is:

  •  - I2C library;
  •  - hardware serial comm. library;
  •  - non-blocking delays library;
  •  - 4bit LCD HD44780 library with arbitrary pinout;
  •  - PCF8583 RTC applications displaying on LCD or sending on serial;
  •  - Blinking LED with non-blocking delays, in both sloted (JALv2 with Jallib) and millis (Arduino) ways.



By example, compiling pcf8583_lcd example for PIC18F46K22, we get:

- with XC8 1.33 in free mode;
 - 77 bytes RAM;
 - 3630 bytes FLASH;

- with C18 3.46 without procedural abstraction:
 - 302 bytes RAM;
 - 18394 bytes FLASH.

- with C18 3.46 with procedural abstraction:
 - 302 bytes RAM;
 - 7050 bytes FLASH.

As a side note, this is compilation result using Jalv2 (considering this, I always wondered why hobbyists have struggled for so long with MCHP C18 compiler!):

- with JALv2.4q3 with Jallib libraries (in fact, the code is even smaller then reported, as JAL counts also the 768 bytes from the AN1310 bootloader):
 - 70 bytes RAM;
 - 2460 bytes FLASH.

There are plans for adding more libraries for graphical displays, Dallas temperature sensors, SD-Card and FAT32 file system, Infrared, 7-seg. LED displays, Stepper and Servo motors and anything else that may be useful.

What is so special at these libraries? Nothing. Except that is a common code across more compilers and languages, including JALv2 and PMP (library in progress) compilers and, apart of the fact that it will offer good features for custom projects and a "common language" which will assure a smooth transition from a language to another, it will provide also an absolute fair platform for "smackdowns" between compilers.

It is a big project and let's hope that I will have the energy to successfully finalize it.
Not yet ready for public, but already functional, the project is online at https://github.com/funlw65/c18-clib

No comments:

Post a Comment