C compilers for Microchip: HI-TECH or CCS? Free or pay?

(2-9-12) I edited this to try and correct some erroneous statements. To see my HI-TECH tutorials, check here -> http://tech-tut.com/hitech

This is now a touchy subject for me. I started reading a book Programming 8-bit PIC Microcontrollers in C…by Martin P. Bates in August. It explains how to write C for MCUs, and I feel that the book does a great job at it. The book focuses on the CCS compiler from CCSINFO.com. You might have read about the cost of this compiler in the big Microcontrollers blog www.tech-tut.com/?p=258. It is $150.00 for the mid-range MCUs. Ok. Keep this in mind. Here’s my story.

Before I tried the CCS compiler I found out that HI-TECH offered a free compiler! Great, a free, full-functioning compiler. So I downloaded it and set it up for MPLAB (Microchip’s wonderfully free IDE). I started writing what I thought to be a great C program to turn an LED on and off with my knowledge gained from “the book mentioned above”. It consisted of a pause function, and two output states to a pin, and two calls to the pause function that I made. Time to compile! ERROR…ERROR…ERROR…NOT VALID…EAT BUGS!!! A free compiler (that code from one compiler wouldn’t naturally work…2-9-12).

I figure that HI-TECH has different syntax for everything under the sun. A “dry your hands before you wash them” approach (Yep. It really isn’t that difficult. 2-9-12). I had a simple solution: I’ll Google “C Syntax HI-TECH”. Returned: Nothing useful. I Googled a bunch of other stuff and found the same returns. I don’t do well with little examples. I want to know the syntax, what a function does, and how to implement it. Then I can decipher examples. Explanation: I did not find anything about syntax, included functions, or anything related to HI-TECH. I did find a comment or two about HI-TECH not sticking to ANSI conformity (This statement probably is the other way around. 2-9-12). I couldn’t write a simple program, and couldn’t find anything simple enough to tell me why it wouldn’t work. The compiler is free, but you pay in the end (and it works if you take the time to learn how it works. 2-9-12).

The other piece of information about the free HI-TECH compiler is that it is not optimized for efficient code. It’s not a secret. They said it themselves on their website. If you bought their compiler your programs would be 50% smaller. In the end, I wrote a bad program that wouldn’t compile, but if it did, it would take up 50% more space than the compiler they offer if you pay for it. The compiler is free, but you pay in the end.

Finally, I did find a little tutorial on how to write a program in HI-TECH. It was ugly. I compiled it for the PIC16F690 and programmed it with the PICKIT2. It compiled and downloaded to the 16F690. It didn’t work when I applied power! The compiler is free, but you pay in the end (I just didn’t know what I was doing. 2-9-12).

Finally, I did something that I know would work. I wrote an Assembly program to test the MCU out. Lots of work for just a blinky light. I’m not good at Assembler code, but it’s free! I used MPLAB to compile it, and I downloaded it with the PICKIT 2 to the 16F690. It worked. The Assembly compiler is free with MPLAB, but you still pay. You have to learn Assembly. Ha ha. Assembly isn’t bad, but it is not very portable. Check out the difference in the datasheets for MCUs. The instruction sets are different from one MCU family to the next. (HINT: this is why good compilers cost money. They have lots of work to do.)

Ok, here’s the end of the story. I just downloaded the demo version of CCS C compiler. I wrote a program with my own little pause function, and toggled an output pin with a pause call in between each state. I wrote it in C as I did before and compiled it. It worked compiled, and I am almost happy. The demo version is limited to only a few MCUs. I do not own any of them. With this in mind I bought the CCS C compiler and wrote this program for the PIC16F690. It compiled and downloaded to the chip and works. You can also buy the compiler (14-bit MCUs) from HVWTECH.com,  DIGIKEY.com, or CCSINFO.com. It is the same cost from any dealer. It supports too many Microchip microprocessors to name, creates very nice code, and it is completely yours.

Oh…I almost forgot. Before I bought the compiler I Googled “CCS C syntax” to see if they had a list of functions and syntax. Well, well, well…CCS must want my business because the first link was just what I Googled…Try it out. Hit the “I’m feeling lucky” button. A whole list of stuff that actually works. Thank you CCS! Yet another reason why I like you (and now why I don’t like you as much. I want to use my Linux machine, but I would have to buy a license for each computer or system. And as far as I know, you can’t use CCS without a connection to the net to check your license. That’s annoying! 2-9-12). Check back because some projects coded in C are coming soon.

Further reading: Programming 8-bit PIC Microcontrollers in C with Interactive Hardware Simulation ISBN: 970-0-7506-8960-1

6 thoughts on “C compilers for Microchip: HI-TECH or CCS? Free or pay?

  1. desejo programador ccs e preço programador em lader com ihm serie 900 para uso industriau

  2. If what I think you are saying is correct, the field of work determines which compiler to use. If you have the money to buy a $2000 compiler and can still turn a profit, then you are justified in that purchase. The hobbiest must use what is low cost and convenient.

  3. LOL. I sure did, but I do not regret it at all. I enjoy the CCS compiler. I tried to like HI-TECH, but I was not happy with its performance. Perhaps that’s because I couldn’t properly learn how to use it?

    I’m sure there are those that like HI-TECH’s compiler. CCS’ main selling point for me was their book of commands. It’s also downloadable as a pdf. I didn’t have to scour the net to learn something new.

  4. Pingback: Update on microcontrollers: Microchip and Freescale compilers (Hi-Tech, MPLAB C, Codewarrior) « Tech Tut