Poll

Which language to you prefer to use for PIC microcontroller/general MCU dev?

Assembly
12 (22.6%)
C
33 (62.3%)
Basic
6 (11.3%)
Other (specify)
2 (3.8%)

Total Members Voted: 40

Author Topic: Which language do you use to code for PIC/other MCUs, and why?  (Read 7145 times)

0 Members and 1 Guest are viewing this topic.

Offline glossywhiteTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 241
Which language do you use to code for PIC/other MCUs, and why?
« on: January 14, 2011, 10:22:44 pm »
Okay, I'm curious as to which language you guys find preferable for coding for PIC & other MCUs. Personally, and as a newcomer, I find assemly incredibly simple and SO logical (counter to what many people say, oddly). I am autistic, so maybe it is my abrupt, logical & lateral thinking mind that draws me to it. I have tried to learn many languages (I once spent almost a year trying to learn Objective C for coding iPhone apps, before abandoning it - elitist Mac coders didn't help much, with their heads up their arses!).

Simple poll; I have given each user 4 votes, as you may like to use more than one, and hence poll them all. A place to discuss the why and how... thanks
« Last Edit: January 14, 2011, 10:35:23 pm by glossywhite »
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9285
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Which language do you use to code for PIC, and why?
« Reply #1 on: January 14, 2011, 10:34:39 pm »
I haven't done any real work on the PIC, but I have done C++ on the mbed (ARM), C and shell script on Broadcom wireless routers (MIPS), and a little C/C++ on the Renesas RX62N (RX).
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline tyblu

  • Frequent Contributor
  • **
  • Posts: 287
  • Country: 00
    • blog.tyblu.ca
Re: Which language do you use to code for PIC, and why?
« Reply #2 on: January 14, 2011, 10:37:36 pm »
100% Haskell.
Tyler Lucas, electronics hobbyist
 

Offline baljemmett

  • Supporter
  • ****
  • Posts: 665
  • Country: gb
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #3 on: January 14, 2011, 10:39:30 pm »
I've said assembly, which is what I've used for all my PIC stuff to date, and C because I really meant C++ on the mbed.  I've tried C on the PIC but never got as far as a successful compilation, and frankly I prefer the nuts-and-bolts of assembly; whether that's because I write C/C++ in the day job and assembly is a nice change, or because it's a constrained system and I like the challenge, I'm not entirely sure!
 

Offline glossywhiteTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 241
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #4 on: January 14, 2011, 10:41:22 pm »
I've said assembly, which is what I've used for all my PIC stuff to date, and C because I really meant C++ on the mbed.  I've tried C on the PIC but never got as far as a successful compilation, and frankly I prefer the nuts-and-bolts of assembly; whether that's because I write C/C++ in the day job and assembly is a nice change, or because it's a constrained system and I like the challenge, I'm not entirely sure!

Nuts and bolts is what assembly is :) - love that you have TOTAL control, not abstracted away by some higher level code. Wonderful.
 

Offline johnmx

  • Frequent Contributor
  • **
  • Posts: 285
  • Country: pt
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #5 on: January 14, 2011, 11:35:17 pm »
I started playing with PICs more than 10 years ago and on that time I made a promise to myself to not touch in C for the first years. I already knew that the best way to learn all about any microcontroller is through assembly and once starting coding in C I would never go back. So during almost 3 years I never wrote a single line in C for the PIC.

Now sometimes I use assembly just to do some small and time critical functions (not very complex). I also use it to develop some small projects with any micro of the PIC10 and PIC12 family.

Oh, I tried once BASIC and JAL (Just Another Language) but didn’t like it.
Best regards,
johnmx
 

Offline Hypernova

  • Supporter
  • ****
  • Posts: 655
  • Country: tw
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #6 on: January 15, 2011, 12:44:46 am »
C all the way, I have yet to encounter a timing critical app down to the clock level which is where you need asm. Although I started on Basic in high school on my avr, where the teacher made sure we knew the holy commandment: "Thal shal not use GOTO!"
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10344
  • Country: nz
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #7 on: January 15, 2011, 01:16:55 am »
Coding in assembly language can definitely be *better* than C if your just looking at the argument from the point of view of the code itself.
However rarely do you ever encounter a situation where assembly is the better choice overall when considering the decision and it's impact as a whole.
(Some exceptions of course are when you absolutely need control over the speed of your code or when the mcu you're using cant really handle C due to its capabilities)

Since you always want your code to be easily understandable by others as well as yourself and also easy to reuse in other projects C just makes more sense. You can write a little in-line assembly in C when needed so C has lots of the advantages assembly has with little of the disadvantages.

Of course this is just my opinion on the subject.
 
« Last Edit: January 15, 2011, 07:20:05 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline EEwannabe

  • Contributor
  • Posts: 38
  • Country: us
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #8 on: January 15, 2011, 04:43:56 am »
I started out with BASIC a long time ago, now I use assembly mostly because I don't trust my C/C++ writing skills yet. 

- Patrick
 

Offline williefleete

  • Regular Contributor
  • *
  • Posts: 109
  • Country: nz
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #9 on: January 15, 2011, 06:28:32 am »
i got hooked on picaxe about 7 years ago so i use basic for that. because of the space limitations of picaxe i have learnt how to write reasonably fast and efficient code and i've done some quite amazing stuff with the limited capabilities of them including a clock, and an 8 digit LED display using 08M's
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20181
  • Country: gb
  • 0999
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #10 on: January 15, 2011, 09:17:26 am »
Okay, I'm curious as to which language you guys find preferable for coding for PIC & other MCUs. Personally, and as a newcomer, I find assemly incredibly simple and SO logical (counter to what many people say, oddly). I am autistic, so maybe it is my abrupt, logical & lateral thinking mind that draws me to it. I have tried to learn many languages (I once spent almost a year trying to learn Objective C for coding iPhone apps, before abandoning it - elitist Mac coders didn't help much, with their heads up their arses!).

I've not tried C on PICs yet but I agree with you sentiments regarding C vs assembler on the PC. I've not done much MCU work and have chosen assembler each time. I did find BASIC easier than both asm and C on the PC so maybe you could give it a go, if you want an easy option.

Another advantage of high level languages is portability and C is the most popular one. Unfortunately lots of BASIC products are very proprietary so are probably not very portable. I've heard about GC BASIC being open source but I don't know how good it is.
 

Offline Jimmy

  • Regular Contributor
  • *
  • Posts: 224
  • Country: au
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #11 on: January 15, 2011, 11:42:21 am »
Mnemonic, Basic, Assembly and  :-[ Processing
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1055
  • Country: fi
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #12 on: January 15, 2011, 01:20:58 pm »
I have used ASM with PICs. Things are simple with ASM when you are doing simple things, but when you start needing things like large value (>8 bit or floating point) arithmetic, string parsing, multitasking operating system or any communications protocol, things go very difficult to maintain very quickly and whole thing becomes a pain and you'll find yourself re-inventing the wheel instead of developing your own system.

I have mostly moved into MSP430 for casual MCU needs, and I use mainly C with it (mspgcc), although it is very beneficial to know the assembly so you can check the compiler output in case of doubt. My current coding philosophy is that do not optimize too early, instead try to obtain smart program algorithm overall. That gets most optimization.

If there are some time critical sections in the code, then they can be optimized into ASM if required, but writing whole complex program in ASM is sheer madness. By complex I mean substantially more complex than simple "led flasher". I think that it does not matter if you use 70 or 90% of code space or 70 or 90% of CPU cycles if it does what you want. The difference between assembly and C is not even that big, unless compiler is flawed somehow. Only in specialized occasions (like in DSP filter kernels), human knowledge of CPU assembly features can shrink speed and code size considerably.

Regards,
Janne
 

Offline DaveW

  • Frequent Contributor
  • **
  • Posts: 284
  • Country: gb
    • WattCircuit
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #13 on: January 15, 2011, 02:05:55 pm »
C all the way, not only does it let you do much more complex stuff than assembly, but more importantly you can port a lot of code straight across processors. You can take an algorithm straight off wikipedia and drop it into your code. Heck, if you wanted to you could rewrite the Arduino functions for a PIC and have lots of code ready to drop in.
At work we write a interface layer containing functions that have all the processor specific code, including inline assembly, then write everything in C on top of that. You can reuse the same code on ARM, Freescale, PowerPC etc, particularly useful if you've done code review
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18092
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #14 on: January 15, 2011, 04:21:07 pm »
I use basic as it's easy (reason is in the name  ;D) but would like to move to C sometime
 

Offline Boloop

  • Contributor
  • Posts: 13
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #15 on: January 15, 2011, 05:29:16 pm »
I remember briefly seeing basic for micro controllers when I was at some Uni intro course. I didn't like it. At the time I had only learnt a little bit of C and PHP. So I had that knowledge to share.

The only real major MCU project I have done yet was a clock, but it synced up to a Remote Radio Source (MSF60 in this case). This project seemed a little bit too complicated for ASM. so it was in straight C. But the fun thing was. I didn't entirely "code" the thing in C. Because I wasn't too sure how to decode the MSF60 time even with their documentation, because what I thought the pulses would look like wasn't exactly 100% what I was getting on the scope. So I just wrote code for the chip to measure 120 pulses (2 minutes) and save them in ram. With the In circuit debugger I dumped the contents of the 120 pulses onto a file on the PC.

Anyway, this file was later read up by a python script so I can quickly and easily see it debug how to write and algo to decode the time/date. Because debugging on it would a timely and painful process. Having to wait for 2 minutes to get at least one whole complete 60 second cycle, which might not always be clean depending on the weather etc... Once I got it working, ported it to C. Ran and debugged that on my desktop, then finally put it on my PIC. Great Success!

There are two things I like about C, it's portability and that it's strict defined types. With writing python I don't feel too safe. But I know what it should do! But I never code in a single language. I like python because it's quick, easy to know where it breaks. It's experimental. It just tells me that I am on the right track for the right algo. And in the above case I would of found out silly little errors much quickly. Like knowing which start of the week is. And paying close attention to when the day of the week starts etc...

Although I have coded in ObjC for the iPhone, so it doesn't really count here. But I dislike this language with a passion. They tried to re-invent the wheel and just cause more trouble that what it's worth to use. And square brackets, really?

Although I haven't properly coded in ASM before. I think it's important to know how compilers work so that people can understand how to code in C better. And not get bogged down in misconceptions about why their code isn't working.

C# is also nice, but I only think windows mobile can run that.

But I voted C, if the software is complex enough and the compiler supports it. I will do it in C++. I don't touch ASM because I haven't come to anything where it's needed for various reasons mentioned here.
« Last Edit: January 15, 2011, 11:14:14 pm by Boloop »
Boloop
 

Offline glossywhiteTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 241
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #16 on: January 15, 2011, 08:10:52 pm »
I remember briefly seeing basic for micro controllers when I was at some Uni intro course. I didn't like it. At the time I had only learnt a little bit of C and PHP. So I had that knowledge to share.

The only real major MCU project I have done yet was a cock, but it synced up to a Remote Radio Source (MSF60 in this case). This project seemed a little bit too complicated for ASM. so it was in straight C. But the fun thing was. I didn't entirely "code" the thing in C. Because I wasn't too sure how to decode the MSF60 time even with their documentation, because what I thought the pulses would look like wasn't exactly 100% what I was getting on the scope. So I just wrote code for the chip to measure 120 pulses (2 minutes) and save them in ram. With the In circuit debugger I dumped the contents of the 120 pulses onto a file on the PC.

Anyway, this file was later read up by a python script so I can quickly and easily see it debug how to write and algo to decode the time/date. Because debugging on it would a timely and painful process. Having to wait for 2 minutes to get at least one whole complete 60 second cycle, which might not always be clean depending on the weather etc... Once I got it working, ported it to C. Ran and debugged that on my desktop, then finally put it on my PIC. Great Success!

There are two things I like about C, it's portability and that it's strict defined types. With writing python I don't feel too safe. But I know what it should do! But I never code in a single language. I like python because it's quick, easy to know where it breaks. It's experimental. It just tells me that I am on the right track for the right algo. And in the above case I would of found out silly little errors much quickly. Like knowing which start of the week is. And paying close attention to when the day of the week starts etc...

Although I have coded in ObjC for the iPhone, so it doesn't really count here. But I dislike this language with a passion. They tried to re-invent the wheel and just cause more trouble that what it's worth to use. And square brackets, really?

Although I haven't properly coded in ASM before. I think it's important to know how compilers work so that people can understand how to code in C better. And not get bogged down in misconceptions about why their code isn't working.

C# is also nice, but I only think windows mobile can run that.

But I voted C, if the software is complex enough and the compiler supports it. I will do it in C++. I don't touch ASM because I haven't come to anything where it's needed for various reasons mentioned here.

Objective C is a headache, but nowhere near as much of a headache as all the stuck-up Mac developers! Talk about snotty, arrogant and unhelpful. Keep well away :)
 

Offline Hypernova

  • Supporter
  • ****
  • Posts: 655
  • Country: tw
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #17 on: January 15, 2011, 09:20:25 pm »
The only real major MCU project I have done yet was a cock

 ;)
 

Offline comox

  • Regular Contributor
  • *
  • Posts: 52
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #18 on: January 15, 2011, 09:56:35 pm »
I develop for Microchip PIC 18s using C.  I use the Hi Tech Software (now Microchip) PIC18 Pro C compiler, which features what is called omniscient code generation.  The "feature" results in better memory allocation and more efficient code, which is specifically beneficial when dealing with multiple source files.
I started my carrier some 20+ years ago in IT as a C developer, so when I became interested in embedded systems development a few years back, C was a logical starting point.  The programs I develop are simply too big to hand-code in assembly (for me, anyways!) and I am much more productive in C.  Also, I am not autistic, and as such care little for assembly :)
I first used the HT Soft "Hi-Tide" Eclipse-based IDE, which I liked from a development perspective, but I moved to the MPLAB IDE when I started doing debugging with the Real ICE module as HI Tide lacked any integration with the Microchip tools.   Microchip has recently released a beta of their next-generation IDE (called MPLAB-X) which promises the best of both worlds: an Eclipse-like IDE with all the integrated debugging and programming functionality with the Microchip tools), however I soon gave up as I was having trouble getting the USB drivers working under 64-bit Windows 7....   I'm going to hold off for the production release...
« Last Edit: January 16, 2011, 10:09:09 pm by comox »
 

Offline Boloop

  • Contributor
  • Posts: 13
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #19 on: January 15, 2011, 11:15:36 pm »
The only real major MCU project I have done yet was a cock

 ;)

Thanks, I edited it now. Shame It doesn't cascade to the quotes :P.
Boloop
 

Offline apex

  • Regular Contributor
  • *
  • Posts: 72
    • Thoughts of a nerd
Re: Which language do you use to code for PIC/other MCUs, and why?
« Reply #20 on: January 16, 2011, 07:11:37 pm »
C.
All the time.
And some times Java for AVRs for things that come straight out of my mind.
apex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf