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

0 Members and 1 Guest are viewing this topic.

Offline triggerTopic starter

  • Full Member
  • ***
  • Posts: 115
  • Helpful? 0
  • It's an op amp, not a gun part.
Free C compiler for PIC?
« on: January 10, 2007, 08:09:56 PM »
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 »
There are 10 kinds of people in this world: those who can read binary, and those who can't.

Offline Militoy

  • Expert Roboticist
  • Full Member
  • *****
  • Posts: 111
  • Helpful? 0
Re: Free C compiler for PIC?
« Reply #1 on: January 11, 2007, 11:51:48 AM »
Quote
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.

http://www.htsoft.com/products/PICClite.php

Offline triggerTopic starter

  • Full Member
  • ***
  • Posts: 115
  • Helpful? 0
  • It's an op amp, not a gun part.
Re: Free C compiler for PIC?
« Reply #2 on: January 11, 2007, 12:59:28 PM »
Quote
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.

http://www.htsoft.com/products/PICClite.php

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?
There are 10 kinds of people in this world: those who can read binary, and those who can't.

Offline Militoy

  • Expert Roboticist
  • Full Member
  • *****
  • Posts: 111
  • Helpful? 0
Re: Free C compiler for PIC?
« Reply #3 on: January 11, 2007, 02:54:09 PM »
Quote
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.
« Last Edit: January 11, 2007, 03:02:05 PM by Militoy »

Offline triggerTopic starter

  • Full Member
  • ***
  • Posts: 115
  • Helpful? 0
  • It's an op amp, not a gun part.
Re: Free C compiler for PIC?
« Reply #4 on: January 11, 2007, 02:59:07 PM »
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.
There are 10 kinds of people in this world: those who can read binary, and those who can't.

Offline JesseWelling

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 707
  • Helpful? 0
  • Only You Can Build A Robot!
Re: Free C compiler for PIC?
« Reply #5 on: January 12, 2007, 09:47:32 PM »
Hey triger...your thing will go out on monday...I just got back...
 
<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 very
open source friendly.

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

Offline triggerTopic starter

  • Full Member
  • ***
  • Posts: 115
  • Helpful? 0
  • It's an op amp, not a gun part.
Re: Free C compiler for PIC?
« Reply #6 on: January 12, 2007, 11:09:37 PM »
Hey triger...your thing will go out on monday...I just got back...
 
<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 very
open 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.
There are 10 kinds of people in this world: those who can read binary, and those who can't.

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
    • Jon's Place
Re: Free C compiler for PIC?
« Reply #7 on: January 13, 2007, 06:22:41 AM »
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.

http://www.huv.com/miniSumo/seeker2/Seeker2Source.zip

- Jon

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Free C compiler for PIC?
« Reply #8 on: January 13, 2007, 09:30:42 AM »
I think CCS C is the best out there, but its also the most expensive . . .
http://www.ccsinfo.com/content.php?page=compilers

I also used C2C . . . I believe it was free at some point, but its not now . . . I dont recommend it as its buggy and handles math poorly . . . but its fine for simple stuff . . .

Offline Militoy

  • Expert Roboticist
  • Full Member
  • *****
  • Posts: 111
  • Helpful? 0
Re: Free C compiler for PIC?
« Reply #9 on: January 13, 2007, 10:21:08 AM »
Quote
I think CCS C is the best out there, but its also the most expensive . . .
http://www.ccsinfo.com/content.php?page=compilers

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?


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Free C compiler for PIC?
« Reply #10 on: January 13, 2007, 10:35:57 AM »
Quote
Have you heard anything (good or bad) about the CCS CAN kit?

Hmmmm Ive only used their compiler . . . havnt heard anything either about it either . . .

Offline snow

  • Full Member
  • ***
  • Posts: 73
  • Helpful? 0
Re: Free C compiler for PIC?
« Reply #11 on: January 22, 2007, 04:59:47 AM »
You might also try MikroC pic compiler: http://www.mikroe.com/en/compilers/mikroc/pic/download.htm

Demo verison allows you to compile up to 2kb code for any 16f device.

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
    • Jon's Place
Re: Free C compiler for PIC?
« Reply #12 on: January 22, 2007, 06:37:06 AM »
I use the command line version of CCS, which was (last time I checked) $125. I use Crimson Editor (free) as my "IDE".

- Jon

 


Get Your Ad Here

data_list