Author Topic: What is the standard programming language for PICs?  (Read 18273 times)

0 Members and 1 Guest are viewing this topic.

Offline microbugTopic starter

  • Frequent Contributor
  • **
  • Posts: 563
  • Country: gb
  • Electronics Enthusiast
What is the standard programming language for PICs?
« on: June 18, 2013, 06:57:56 pm »
Hi,
I am beginning with microcontrollers in general - I have a few ATMEGAs + an Arduino, and I like using them (Atmels) a lot because you can program them in C.
I had a quick look into using PICs as they seem to be (correct me here) more common, and that must be for a reason. However, when I looked into it all I could see with regards to options was PICAXE and assembly. Are PICs normally programmed in assembly language or is it possible to program them in C / C++?
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: What is the standard programming language for PICs?
« Reply #1 on: June 18, 2013, 07:00:24 pm »
PICs, like every other MCU, are programmed using whatever method/language/development environment you choose to use.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline microbugTopic starter

  • Frequent Contributor
  • **
  • Posts: 563
  • Country: gb
  • Electronics Enthusiast
Re: What is the standard programming language for PICs?
« Reply #2 on: June 18, 2013, 07:08:27 pm »
OK, I will revise my question: what is the most popular development environment for PICs and is there a popular one I can use that will allow me to program in C?
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13745
  • Country: gb
    • Mike's Electric Stuff
Re: What is the standard programming language for PICs?
« Reply #3 on: June 18, 2013, 07:17:11 pm »
OK, I will revise my question: what is the most popular development environment for PICs and is there a popular one I can use that will allow me to program in C?
Yes, Microchip's C compilers - there are free versions with poor code optimisation - this is mostly an issue on the 8-bit range, which need a cleverer compiler to deal with the limitations of the architecture. AFAIUI the 16 and 32 bit ones show less difference between the free and full versions.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline lorth

  • Contributor
  • Posts: 46
  • Country: us
Re: What is the standard programming language for PICs?
« Reply #4 on: June 18, 2013, 07:18:56 pm »
OK, I will revise my question: what is the most popular development environment for PICs and is there a popular one I can use that will allow me to program in C?

Microchip´s MPLAB X is now the "standard" I guess, but I tried a year a go and use it for a bit, but being used to the older versions I had to go back to those... I guess now is probably better. Then get the compiler for the family (8,16/dsPIC, 32bit...) and thats it.

You can program in assembly or C using the API provided... If you have more time and want to learn more, you can just get the datasheet and program the registers yourself (That is how I used to do it...)
 

Offline ivan747

  • Super Contributor
  • ***
  • Posts: 2045
  • Country: us
Re: What is the standard programming language for PICs?
« Reply #5 on: June 18, 2013, 09:47:12 pm »
OK, I will revise my question: what is the most popular development environment for PICs and is there a popular one I can use that will allow me to program in C?
Yes, Microchip's C compilers - there are free versions with poor code optimisation - this is mostly an issue on the 8-bit range, which need a cleverer compiler to deal with the limitations of the architecture. AFAIUI the 16 and 32 bit ones show less difference between the free and full versions.

I was coding some if (TMR0>=n) conditionals and when I looked into the assembly listing it almost seemed like if they were deliberately adding unnecessary goto's and instructions in the code. It was for software PWM to control servos. Manually coding the routine in asembly made it 3x faster.

This was in a 12F part by the way, using the free XC8.
« Last Edit: June 20, 2013, 12:00:08 am by ivan747 »
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: What is the standard programming language for PICs?
« Reply #6 on: June 18, 2013, 09:52:37 pm »
Not a surprise, XC8 is truly miserable. I really rarely bother with C for programming 8-bit PICs these days - I'll sometimes use it for simple, branch-heavy, somewhat boring stuff like the UART interface, but otherwise I just don't bother with the crappy compiler.
No longer active here - try the IRC channel if you just can't be without me :)
 

Online ve7xen

  • Super Contributor
  • ***
  • Posts: 1193
  • Country: ca
    • VE7XEN Blog
Re: What is the standard programming language for PICs?
« Reply #7 on: June 18, 2013, 09:55:03 pm »
I just don't bother with the crappy compiler - by using a different arch :P.

Isn't PIC32 a MIPS core? Then you can just use gcc and not worry about for-profit toolchains?

Sometimes it seems to me that these MCU vendors think their product is the tools, not the MCUs themselves.
73 de VE7XEN
He/Him
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: What is the standard programming language for PICs?
« Reply #8 on: June 18, 2013, 09:57:30 pm »
I like PICs, though, when I don't have to screw around with their compiler. And yes, PIC32 is MIPS (another one ridiculously easy to program in assembly, by the way  :-+). Fortunately, AVR (which I use about as often) can be used with GCC.
No longer active here - try the IRC channel if you just can't be without me :)
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13745
  • Country: gb
    • Mike's Electric Stuff
Re: What is the standard programming language for PICs?
« Reply #9 on: June 18, 2013, 10:06:50 pm »
The full version of the 8-bit compiler is pretty good - I've used it for parts as small as 10F200 with nontrivial functionality.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13745
  • Country: gb
    • Mike's Electric Stuff
Re: What is the standard programming language for PICs?
« Reply #10 on: June 18, 2013, 10:08:57 pm »
I just don't bother with the crappy compiler - by using a different arch :P.

Isn't PIC32 a MIPS core? Then you can just use gcc and not worry about for-profit toolchains?

Sometimes it seems to me that these MCU vendors think their product is the tools, not the MCUs themselves.
Both PIC24 and 32 are based on GCC - ISTR reading you can work around most or all of the non-optimisations of the free versions of these with some additional command line options.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: What is the standard programming language for PICs?
« Reply #11 on: June 18, 2013, 10:58:47 pm »
Both PIC24 and 32 are based on GCC - ISTR reading you can work around most or all of the non-optimisations of the free versions of these with some additional command line options.
Yes, and you can also download the source code and recompile for a full version (or, if you don't mind straying into a bit of gray area, look exactly at how the compiler interacts with the license server).

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: What is the standard programming language for PICs?
« Reply #12 on: June 18, 2013, 11:08:57 pm »
Hi,
I am beginning with microcontrollers in general - I have a few ATMEGAs + an Arduino, and I like using them (Atmels) a lot because you can program them in C.
I had a quick look into using PICs as they seem to be (correct me here) more common
For hobby like projects perhaps (which is why there are so many websites with 8 bit PIC projects) but you won't find many PICs in real products. If you want to program a PIC in C you need to buy the Hitech C compiler which isn't cheap so you need to sell lots of hardware to recoup the price difference. Hence so many PIC projects get programmed in assembly... OTOH GCC based tools for ARM microcontrollers in general or TI's MSP430 are completely free with full optimisation.
« Last Edit: June 19, 2013, 12:22:32 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: What is the standard programming language for PICs?
« Reply #13 on: June 19, 2013, 02:45:49 am »
There are "many" C compilers, plus some Basic Compilers, plus "JAL", for 8-bit PICs (PIC10, PIC12, PIC16, PIC18.)  Most are "not free" but have free versions with various limitations.  Microchip's own 8-bit C compiler is particularly annoying in its "no optimizations in the free version" strategy; it produces truly AWFUL code.  I've used CC5X, and found it quite acceptable (for the processors it supports.)

The 16bit PICs (PIC24, PIC30, PIC33) and the 32bit PICs (PIC32) have fewer options, but the Microchip C compilers are based on gcc, and so aren't quite as bad in their free versions (plus there is the "build-your-own" option.)  PIC32 is MIPS-based, and so theoretically is widely supported.
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: What is the standard programming language for PICs?
« Reply #14 on: June 19, 2013, 03:00:13 am »
Quote
but you won't find many PICs in real products.
Really?
I find quite the opposite to be the case, or rather not the opposite, but I see just as many PICs of various flavors as I see Atmel, various 8051 type incarnations, Motorola 8 bit types, and so on.
To generalize and say "won't find PICs in real products" is just plain incorrect.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: What is the standard programming language for PICs?
« Reply #15 on: June 19, 2013, 03:24:14 am »
For hobby like projects perhaps (which is why there are so many websites with 8 bit PIC projects) but you won't find many PICs in real products.

Lol Microchip shipped its 12 billionth PIC processor in May this year, 10 months after shipping its 11 billionth.

100 million a month - must be a lot of busy 'makers' out there.
 

Offline glatocha

  • Regular Contributor
  • *
  • Posts: 114
Re: What is the standard programming language for PICs?
« Reply #16 on: June 19, 2013, 04:02:13 am »
Also, As I am register to the Microchip newsletter I got lately two emails from the CEO that they cannot handle production as they have so many orders.
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: What is the standard programming language for PICs?
« Reply #17 on: June 19, 2013, 05:01:45 am »
I still see more 8051 variants (including some from Atmel), but then followed by PIC, followed by AVRs. And the AVRs hardly sticking out from the crowd.

For 32 bit it is ARM, then ARM, followed by ARM :) And then some more.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline millerb

  • Regular Contributor
  • *
  • Posts: 71
  • Country: us
Re: What is the standard programming language for PICs?
« Reply #18 on: June 19, 2013, 05:37:02 am »
Regarding PIC compilers, I like mikroC from MikroElektronika.
 

Offline caroper

  • Regular Contributor
  • *
  • Posts: 193
  • Country: za
    • Take your PIC
Re: What is the standard programming language for PICs?
« Reply #19 on: June 19, 2013, 08:29:57 am »
Hi,
I am beginning with microcontrollers in general - I have a few ATMEGAs + an Arduino, and I like using them (Atmels) a lot because you can program them in C.

If you already have experience with the Arduino then I recommend that you start with ChipKIT http://chipkit.net/.  It uses the PIC32MX devices, a MIPS Core with all the normal PIC peripherals. 

The IDE is the same one you are already used too, MPIDE, but supports both ChipKIT (PIC) and Arduino (AVR) platforms. It uses the GCC compiler and is even compatible with (most of) the Arduino Libraries, saving you a lot of headaches in your initial experiments.

Microchip have released a PIC32MX in a Dip Package suitable for Hobbyists, and it includes a Bootloader http://www.microchipdirect.com/ProductSearch.aspx?Keywords=TCHIP-USB-MX250F128B so no expensive Programmer is required.

Take a look at my thread on this forum about using this Chip on a breadboard, or hop on over to my new blog at http://caroper.blogspot.com/. I have just started a tutorial series to introduce hobbyists and students to the PIC32MX.

Cheers
Chris
« Last Edit: June 19, 2013, 08:33:16 am by caroper »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: What is the standard programming language for PICs?
« Reply #20 on: June 19, 2013, 11:00:07 am »
For hobby like projects perhaps (which is why there are so many websites with 8 bit PIC projects) but you won't find many PICs in real products.

Lol Microchip shipped its 12 billionth PIC processor in May this year, 10 months after shipping its 11 billionth.

100 million a month - must be a lot of busy 'makers' out there.
That still doesn't make getting into the 8 bit PICs a wise choice. None of the professional embedded engineers I know would choose for a PIC. Most people who put an 8 bit PIC into a design don't know other processors so for them the PIC is a hammer which makes everything look like a nail. Just ask why people use a PIC. Most will say 'because I know it'. Not because its good or the best fit. Just look at the number of people complaining about silicon bugs in Microchip controllers.

I recently did some software development for a customer for a new (high volume very cost sensitive) design. The customer intended to use a PIC. I pushed an MSP430. It appeared the MSP430 costs about the same, uses about 3 times less power so a smaller battery would suffice AND took less time to write software for.

What I'm saying is that if someone wants to get into using microcontrollers he/she should not use some archaic architecture from the 70's which also needs spending serious cash to get decent tools.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8269
Re: What is the standard programming language for PICs?
« Reply #21 on: June 19, 2013, 11:53:07 am »
I still see more 8051 variants (including some from Atmel), but then followed by PIC, followed by AVRs. And the AVRs hardly sticking out from the crowd.

For 32 bit it is ARM, then ARM, followed by ARM :) And then some more.
Same here. An AVR in a commercial consumer product is very rare. On the 32-bit side MIPS seems to be a bit more popular for the Chinese, in tablets and routers.

I think it's been said before on this forum that the advantage of PICs is not ease of use or cost of dev tools, it's availability; which is more important when you have products that need long production runs. The same reason 8051 stays around - it's a pretty constrained architecture but it's been around for so long and so many vendors sell them. (Similar situation with the 6502, and Z80, although not nearly as much.)
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: What is the standard programming language for PICs?
« Reply #22 on: June 19, 2013, 12:05:38 pm »
Due to Broadcom the MIPS architecture has a strong foothold in routers and setop boxes but for general purpose its no match for ARM. I once had to work on a MIPS based Linux device but if you are working for a small company then (community) support is hard to come by. And MIPS32 has some 'quirks': it executes the instruction after a jump before jumping. That can make programming them in assembly tricky because it is easy to forget (as I found out myself).
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: What is the standard programming language for PICs?
« Reply #23 on: June 19, 2013, 12:20:46 pm »
And MIPS32 has some 'quirks': it executes the instruction after a jump before jumping. That can make programming them in assembly tricky because it is easy to forget (as I found out myself).

Huh ?  ??? Mind elaborate further with simple explanation or example ? Really curious.  :o

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8269
Re: What is the standard programming language for PICs?
« Reply #24 on: June 19, 2013, 12:36:12 pm »
http://en.wikipedia.org/wiki/Delay_slot
Basically an artifact of the RISC fad.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf