Microchip C Compilers - which free compiler do you use? - Page 1
Forum section: electronics / general

author: andyg
author_rank: Regular Contributor
timestamp: July 04, 2011, 09:09:25 am
content: HiI would like to get into using PIC MCUs. I have mainly used AVR in the past using avr-gcc which is free.I was wondering what people are using out there with regards to PIC compilers which are free. From what I can see:MPLAB C - doesn't work for PIC12/16, but for the other devices it supports, some optimisations are crippled after 60 daysHiTech C - free version has crippled optimisationsCCS - not freeWhat do you guys use? Are you paying, or just live with the crippled features? Is the disabled optimisations versions still okay for general projects?Andy

author: oPossum
author_rank: Super Contributor
timestamp: July 04, 2011, 02:38:47 pm
content: I recommend beginning with the 16 bit PIC (24H/24F/30F/33F series). The GCC derived compiler for those parts that is part of MPLAB is much more like AVRGCC than any of the compilers for the 8 bit PICs.TheMicrostickis a nice low cost way to get stared with the 16 bit PICs. It has an integrated programmer and debugger, so you don't need any additional hardware to get started.

author: cyberfish
author_rank: Regular Contributor
timestamp: July 04, 2011, 04:45:25 pm
content: Is there a specific reason you want to switch to PIC?For free tools, AVR is much better. I used SDCC for PIC before, but it's fairly limited and buggy. According to friend that's a PIC assembly expert, it also generates very un-optimal code.If you want more power, ARM (ARM7/ARM9/Cortex) is another platform with great open source tools.

author: Nermash
author_rank: Frequent Contributor
timestamp: July 04, 2011, 08:46:16 pm
content: I have used Hitech free version for 12F and 16F pics, and I am currently working with C18 trial compiler on 18F2685 chip, mainly due to the fact that Microchip TCP IP stack natively supports it.Both are fine for me, altough I sometimes hit syntax limitations in these compilers,probably being "spoiled" with C++ uni educationFor me personally free version of both are fine, I tend to lean toward Hitech, but that's just because I started with it in the first place. IMHO, for general type of personal projects I would recomend free versions, optimisations come in to play with big number theory, penny saving and micromanagement.

author: johnmx
author_rank: Frequent Contributor
timestamp: July 04, 2011, 09:26:07 pm
content: I use the following compilers:PIC10/12: MPASM (Assembler)PIC16: HI-TECHPIC18: MPLAB C18PIC24: MPLAB C30PIC32: MPLAB C32The only issue I have with the free limited versions is when I want to compile the bootloader program for some micros.If I need a fully optimized (for speed or time execution) function, I write it in assembly.

author: cyberfish
author_rank: Regular Contributor
timestamp: July 04, 2011, 09:30:21 pm
content: Optimization is helpful because it allows us to write easily readable code and leave it to the compiler for low level optimizations.Eg. without optimizations, you'll have to write multiplications and divisions by powers of 2 as shifts, if you want them to execute in reasonable time (and code space). No need to worry about that if you have optimization, because all modern compilers are smart enough to do that for you.Other examples include loop unrolling, and function inlining. They all make the code very ugly if you want to optimize in C by hand.That's why I would not use a non-optimizing compiler. Clean code is easy to read, easy to maintain, and easy to spot bugs in.

author: bxs
author_rank: Regular Contributor
timestamp: July 04, 2011, 10:04:09 pm
content: *For me, 8bit:- Baseline Architecture (PIC10, PIC12, PIC16) -> ASM- Mid-Range Architecture (PIC12, PIC16) -> ASM / HI-TECH C- Enhanced Mid-Range Architecture (PIC12FXXX, PIC16F1XX) -> HI-TECH C- PIC18 Architecture (PIC18) -> MPLAB C18*For 16bit and 32bit -> MPLAB C compilers.For personal use, free versions are fine.In case of PIC32 you can also look at CHIPKIT:http://www.microchip.com/chipkithttps://github.com/chipKIT32/chipKIT32-MAX/downloadshttp://www.chipkit.org/forum/

author: RCMR
author_rank: Frequent Contributor
timestamp: July 05, 2011, 04:46:24 am
content: I use the Hitech C for PIC16 work and the Microchip C18 for PIC18 work.Both are perfectly adequate but I do like the libraries in the Hitech compiler -- can save a bit of time when compared to using C18.As for the AVR vs PIC debate -- fortunately much of the difference in CPU architecture is hidden when you're using C so it becomes somewhat moot.PICs are cheap and plentiful and there's a wonderful underlying consistency within each family, Atmel's processors can become pretty hard to find at times.However, it's horses for courses and the bottom line is -- it's all good!

author: andyg
author_rank: Regular Contributor
timestamp: July 05, 2011, 07:34:59 am
content: Thanks,Its interesting to see what people are using.@cyberfish: I'm not really "switching", just wanted to learn a different MCU and I know PIC is pretty popular. Plus I liked the fact you could debug your program with the PicKit. I'll look at the ARM Cortex based MCUs too.Not sure what do do yet. Just wanted to learn some PIC but not willing to pay $$$ for a compiler yet. But it sounds like the free limited optmisation versions might be okay to use.

author: cyberfish
author_rank: Regular Contributor
timestamp: July 05, 2011, 08:55:46 am
content: Debugging with PicKit is definitely a very big advantage. Cortex has that, too. JTAG programming + debugging with a $30 dongle (or build your own, which is essentially just a FTDI breakout board).I think PICs have better/more peripherals compared to AVR, but for free toolchain, AVR is definitely the way to go.avrgcc is state of the art official compiler, that's free and open source. Doesn't get much better than that. ARM is similar.If you just want to try another MCU, I think ARM would be a good idea because of the better open source tools (GCC/GDB), and it's also more "different".