Author
Topic: Free C compiler for PIC? (Read 12057 times)

I'll be working on a PIC 16xFx soon, and I can't find a free C compiler out there (other than the CCS/Hitech demos). I've worked in assembly before and can swing that, but I'd prefer C. Any thoughts?

Edit: I found ONE that is totally free (though demo-limited). It's the CC5X compiler (http://www.bknd.com/cc5x/introduction.shtml). Anyone have any experience with this? The demo says that it is limited to 1024 instructions in any single C module. How do they expect us to know how many instructions our code will produce until we compile it? Weird.

« Last Edit: January 11, 2007, 12:06:44 AM by trigger »

Logged

There are 10 kinds of people in this world: those who can read binary, and those who can't.

I'll be working on a PIC 16xFx soon, and I can't find a free C compiler out there (other than the CCS/Hitech demos).

Is the "CCS/Hitech demo" that you mentioned Hi-Tech's PICC-Lite? I actually thought that one looked pretty good for a freeware ANSI C compiler - even though it will only target a limited range of PIC12F and PIC16F processors. I had even thought of trying to do a download, and running some canned C code through it to see how it works - though most of my PIC16 code is targeted towards the PIC16F72 - and that apparently doesn't fall into the freeware compiler's capabilities.

I'll be working on a PIC 16xFx soon, and I can't find a free C compiler out there (other than the CCS/Hitech demos).

Is the "CCS/Hitech demo" that you mentioned Hi-Tech's PICC-Lite? I actually thought that one looked pretty good for a freeware ANSI C compiler - even though it will only target a limited range of PIC12F and PIC16F processors. I had even thought of trying to do a download, and running some canned C code through it to see how it works - though most of my PIC16 code is targeted towards the PIC16F72 - and that apparently doesn't fall into the freeware compiler's capabilities.

CCS has its own demo (30 day limited), and yes, I was referring to PICC-lite when I mentioned Hi-Tech. I'm concerned by its limitations for my PIC (16F877). It says it only allows "2 RAM banks, 2K program memory supported." Maybe this is plenty, but I don't know. I'm used to programming on PCs, not MCUs, and 2K doesn't sound like a lot. Also, I wonder what it means by "2 RAM banks." Do you know?

Logged

There are 10 kinds of people in this world: those who can read binary, and those who can't.

It says it only allows "2 RAM banks, 2K program memory supported." Maybe this is plenty, but I don't know.

Quote

Also, I wonder what it means by "2 RAM banks." Do you know?

On sheet 12 of the datasheet for the PIC16F877, you'll see that the General Purpose Registers are split up into 4 "banks", each containing up to 7Fh (128 bytes) of 8-bit instructions. It looks to me from sheet 3 that the max number of instructions the chip will hold in program memory is 368 8-bit bytes. The compiler seems to be limited to using 256 bytes. So from what I can gather, with this compiler, you can use 2/3 of available memory for this device.

It will take a better programmer than me to tell you what you can achieve with 256 instruction registers - I'm much more involved with and adept at hardware than firmware, and when I run out of I/O pins (which happens to me way faster than memory) I tend to just add another processor to my bus. This chip also has an instruction set of only 35 1-word instructions. That can work for you, as well as against you. I will say that I've used the "little brothers" of this processor, including the part I mentioned above (with even less memory space), for some fairly complex controllers in military systems - so depending on what you are trying to achieve, you may have plenty of space. As a side note - you are probably already aware that programming in assembly instead of a higher-level language like C will save you memory space.

On sheet 12 of the datasheet for the PIC16F877, you'll see that the General Purpose Registers are split up into 4 "banks", each containing up to 7Fh (128 bytes) of 8-bit instructions. It looks to me from sheet 3 that the max number of instructions the chip will hold in program memory is 368 8-bit bytes. The compiler seems to be limited to using 256 bytes. So from what I can gather, with this compiler, you can use 2/3 of available memory for this device.

It will take a better programmer than me to tell you what you can achieve with 256 instruction registers - I'm much more involved with and adept at hardware than firmware, and when I run out of I/O pins (which happens to me way faster than memory) I tend to just add another processor to my bus. This chip also has an instruction set of only 35 1-word instructions. That can work for you, as well as against you. I will say that I've used the "little brothers" of this processor, with even less memory space, for some fairly complex controllers in military systems - so depending on what you are trying to achieve, you may have plenty of space. As a side note - you are probably already aware that programming in assembly instead of a higher-level language like C will save you memory space.

Thanks! This is helpful. Maybe I'll try both CC5X and PICC-lite and see which works out better in the end.

Logged

There are 10 kinds of people in this world: those who can read binary, and those who can't.

<soap box>Anyways I highly recomend that for pic's you program in assembly...if you want to program in C get an AVR because they are made for programing in C and overall you will save more money in free compilers and community support. AVR is veryopen source friendly.

Pic's are made for programing in assembly if you ask me...that's why there are only 35 instructions....</soap box>

<soap box>Anyways I highly recomend that for pic's you program in assembly...if you want to program in C get an AVR because they are made for programing in C and overall you will save more money in free compilers and community support. AVR is veryopen source friendly.

Pic's are made for programing in assembly if you ask me...that's why there are only 35 instructions....</soap box>

Thanks! I've been looking at the instruction set and some sample code, and it does not look that bad. The ASM I used in college was awful, so I was dreading doing it again. But the PIC ASM seems to have actual modular-code friendly features. I'll definitely give it a try. The C compilers on the other hand seem to have very little in the way of sample code or community support, as you indicated.

Logged

There are 10 kinds of people in this world: those who can read binary, and those who can't.

When I program PICs, I use CCS C. It has great support for the hardware features of the chip. You can see an example of a fairly complex C program I wrote for it on my Seeker 2 mini-sumo page, where I have a link to the source code.

Admin - I notice that CCS has a CAN bus development kit, including the compiler, for $549. I think I paid around $300 for the Microchip CAN-LIN-2 demo board - without a compiler. Have you heard anything (good or bad) about the CCS CAN kit?