# What is the best C Compiler for PIC16F877A?

#### dimastar85

##### New Member
What is the Best, Recommended Free C Compiler for PIC16F877A?
What is the site that provide a good tutorial on that C Compiler?
(I know Assembly but i am given a difficult task which is: *Program PIC16F877A using C*)
If can, hope kind person can at least post a simple example of how to make a LED blink by C (PIC16F877A)..I'm frustrated... really need helphm:

To any senior,guide me please,thank you...

#### William At MyBlueRoom

##### New Member
The B Knudsen CC5X is supported by MPLAB. The free version supports up to 1K of code. (More than enough to blink an LED)

http://www.bknd.com/cc5x/

#### raedbenz

##### New Member
hi man,,i was facing the same problem,,i was looking for C tutorials for PIC all the time..
The best whay is to learn C language in general (search for tutorials online),then try to relate the register and ports with C language,,
a recommended complier is the MikroElektronika.(up to 2kb program size).also u can download a C _syntax as a help .
www.mikroe.com

#### sci-3d

##### Member
sdcc also supports Microchip PIC16 and PIC18 series.

#### evandude

##### New Member
William At MyBlueRoom said:
The B Knudsen CC5X is supported by MPLAB. The free version supports up to 1K of code. (More than enough to blink an LED)

http://www.bknd.com/cc5x/
Another similar one that I suggest is BoostC ( http://sourceboost.com/Products/BoostC/Overview.html ) It has its own IDE, but it is also supported by MPLAB if you choose to use it there. In MPLAB it supports C-source-level simulation and in-circuit debugging and all that. The free version has a 2k code limit (twice what CC5x has) and the full versions are much cheaper if you switched over ($30-70 depending on the type, vs.$200+ for CC5x), and on top of all that, BoostC has better optimization than the free version of CC5x; in my experience it was actually close to being as good as the optimization of the full version of CC5x (when you compile with the free CC5x it teases you with the code size due to the optimization you would be getting if you bought it) And, it's developed by a couple of really nice guys who run a forum on their site and are really helpful if you run into any trouble. The syntax and all that are relatively similar to CC5x, I myself switched from CC5x to boostC and only had to make minor changes to get things to compile in one or the other (mainly capitalization differences in SFR #define's, etc)

BoostC also natively supports all the PIC series from 10F up to 18F, whereas many other compilers (such as cc5x) have a separate version for 18F series (with no free version available). This may not be a big deal as many people (myself included) choose to use the microchip-standard C18 compiler for the 18F series PICs, which has a free version that is practically unlimited as far as hobbyist use is concerned.

I also have a couple of example programs for boostC on my website, including a "hello world" type of program that simply flashes LED's connected to any of the output pins. http://eegeek.net/content/view/30/32/

Last edited:

#### ombrastein

You get 90 days of support with the initial purchase. After that a $100 a year support fee allows you to download the latest version. A NICE thing is that they allow you to buy support (read upgrade) at any time. It does not need to be continous. #### evandude ##### New Member 3v0 said: Whe I started working with PIC16F's I used the CCS compiler... CCS seems like a decent package, but I was turned off from it because of the extremely proprietary feel of the example code I found... This screenshot (given as an example image on microchipC.com) is a prime example: every single line of code inside the main() routine is using proprietary functions for simple tasks, instead of just doing things manually which would have taken about the same number of lines of code. Sure, it's easily readable by someone unfamiliar with the code, but to me it seems too much like BASIC, and it would be completely non-portable to other compilers without re-writing all of that stuff. Because there really is not enough example C code for PICs on the internet, it seems counterproductive for hobbyists to be writing such proprietary code, rather than code that will be more easily portable to different C compilers. Of course, I've not actually used CCS enough to see if you CAN write more portable code with it (I would imagine you could) but it seems to encourage users not to bother. #### 3v0 ##### Coop Build Coordinator Forum Supporter evandude said: CCS seems like a decent package, but I was turned off from it because of the extremely proprietary feel of the example code I found... This screenshot (given as an example image on microchipC.com) is a prime example:. I agree that it would be bad form to write code in an overly proprietary way. The good news is that what you see is a collection of bells and whistles. You do not have to use them. IMHO you are better off in most cases if you do not. I dug around and found P. Anderson's text http://www.phanderson.com/PIC/PICC/pic_c_routines.html which caused me to look into the CCS compiler. It is in the section marked compiler. There is more to his discussion then the one paragraph that follows but it makes the main point. In fact, I started with the$850 High Tech PIC C package, on the general theory that the more you pay, the more you get. After fussing for a month where crossing the simplest of bridges took far too long, I used a number of other compilers, ranging in price from free to \$100 and finally settled on the CCS as more than adequate and quite affordable for the hobbyist.
I have a lot of respect for Professor Anderson. He has done a lot of work to promote embeded programing as a hobby.

Note that I myself have not tried the other PIC compilers. But as I said earlier, I have used a lot of cross compiler. CCS's offering is solid.

3v0

#### meera83

##### New Member
recently, i m asking to do a project using PIC16F877A..

but i now confising that what the different between using MPLab to write program compare to using Turbo C++??is it the contain(i mean the sentences) to write is defferent??

so sorry if i ask a stupid question, since my knowledge about programming is very very poor..

#### meera83

##### New Member

is it MPLab a compiler? then CCS also a compiler,right??

i just know that my school got a PIC 16F877A interface board for install the programming after i write it..the compiler i choose is it need to consider with what kind of interfce board i use??

thank...

#### Nigel Goodwin

##### Super Moderator
meera83 said:

is it MPLab a compiler? then CCS also a compiler,right??
No MPLAB is a complete programming 'system' including editor and simulator - PLUS it includes MPASM the MicroChip assembler (not compiler) which assembles source code (written in PIC assembler) and produces a HEX file for transferring to the PIC.

CCS C is a high level compiler, which converts the C code to assembler, then to a HEX file.

i just know that my school got a PIC 16F877A interface board for install the programming after i write it..the compiler i choose is it need to consider with what kind of interfce board i use??
Makes no difference - the code is converted to a HEX file, which you then transfer to the PIC with a programmer.