Fighting for space on a 12F675 device - Pascal like languages

Post date: Apr 16, 2011 2:51:29 AM

1. About the device

The PIC12F675 is a little 8pin microcontroller device which has some interesting features. Is cheap, ideal for beginners and can be freely supported by many commercial languages on the market.


The device can be used in a reasonable variety of projects as Windmill/Solar controllers/loggers, Water pump controllers, Stepper motor drivers, Alarms and Automotive applications, etc.

2. About our mission

For such a device, the only thing desired from actual languages/compilers on the market (commercial or freeware) is to obtain the smallest code possible, without much effort form the user. But this objective is harder and harder to attain with the modern compilators which must come with support for the most recent devices from Microchip and with the best featured library possible - I always said that these days, with the powerful microcontrollers available at competitive prices, a feature rich library is more important that the ability to produce the smallest code. A language/compiler which come with easy support for USB, SD Card, Network and USB & Network bootloaders can be the winner. Because this can also assure a large online community of users.

But what is happening with the support for our older and smaller devices? It is a common practice to make common libraries to support a large family of microcontrollers but the price is high for small devices - more and more space memory occupied from a version to another of actual compilers. Older projects can't compile on newest version of libraries/compilers.

So, let's see what is the situation for 12F675 device and Pascal like languages/compilers today. Initially, we will use a small project consisting of a small Windmill/Solar controller and later, a more complex logger application.

3, The compilers and tools used

Here are just three compilers - don't know for others.

  1. mikroPascal PRO 4.60;
  2. Pic Micro Pascal;
  3. JALv2 2.4n with Jallib 0.6

The tools I used to program and test the microcontroller:

  1. Pickit2 programmer;
  2. Low Pin Count Demo board modified by me to make it more useful for 8pin microcontrollers;
  3. My Windmill/Solar controller board for live test.

4. Testing using standard libraries

The examples will use the standard ADC libraries provided by the toolchain. Again, the standard libraries are designed to provide functionality for the all supported microcontrollers.

4.1 Simple Windmill/Solar controller:

*Note: The standard library for Analog to Digital conversion from PMP can not be used on 12F675 device without modifications. Oshonsoft Basic was introduced recently just to see where is situated, compared with the others (it is the best PIC simulator in the world but as compiler not as good as PMP and JALv2) - sorry for inconvenience.

The sources are included inside "" archive - see the attachments.

5. Testing using custom libraries/functions

The examples will use custom ADC functions, designed specially for the microcontroller in case. The advantage is obvious - no bloated code and a better optimization. As you can see in the table bellow, is the only solution when you work with such devices. The downside is that this is not for beginners...

5.1 Simple Windmill/Solar controller:

The sources are included inside "" archive - see the attachments.

5.2 Windmill/Solar controller and logger:

The reference design can be found there, here will be only the firmware as a test (not sure yet, maybe first I will post there the modified project). This will not work with standard libraries so it is posted on this section only - I will try to keep the 32bit integer math for calculating required voltages. Otherwise, an adjustable voltage power supply is mandatory - no big deal but it will take some time, my variable power source is down.

--- to be completed ---