Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 7th December 2006, 05:42 PM   #1
Default Best programming Language??

HI,..
i am intending to start learnig C or Basic for programming PIC's..
which language do you recommend(except assembly).??
raedbenz is offline  
Old 7th December 2006, 06:10 PM   #2
Default

The language that gets the job done is the best language.

Learn assembly. It will force you to understand how the PIC works which will make you a better programmer when it comes to using high level languages.

Once you master that, C is high level language of choice for the PICs.

Why on Earth would you dismiss assembly?
phalanx is offline  
Old 7th December 2006, 07:26 PM   #3
Default

I see assembly recommended all the time, but I think it makes more sense to learn a high level language first and be comfortable with it before delving into the detail of assembly.

Mike
upand_at_them is offline  
Old 7th December 2006, 07:52 PM   #4
Default

Quote:
Originally Posted by raedbenz
HI,..
i am intending to start learnig C or Basic for programming PIC's..
which language do you recommend(except assembly).??
Hi

i will also join you and i feel you can learn C --however, assy language is manytimes required as support. Particularly when you have to fit the code into small space-- optimization by other languages may not be that efficent as what you could do -- not at amature level but after gaining experience.

So, all the best
__________________
Regards,
Sarma.
mvs sarma is offline  
Old 7th December 2006, 09:00 PM   #5
Default

Quote:
Originally Posted by upand_at_them
I see assembly recommended all the time, but I think it makes more sense to learn a high level language first and be comfortable with it before delving into the detail of assembly.
In my opinion, while that might be true in some cases, I don't think it is true for microcontrollers. PICs aren't at all the same as PC's, where many things are abstracted away from you... There's no command line terminal where you can print a nice "hello world" message on a PIC! Instead you're always programming with a direct interface to the hardware, so you really have to understand the hardware. As phalanx states, assembly will force you to understand the hardware better. One of the biggest reasons in my mind is that the PIC is pretty limited in its capabilities, so you should always be conscious of what kind of assembly code your program written in C or BASIC is going to compile into. On a computer, you don't even think about things like multiplying and dividing 32-bit integers or performing floating-point math... but on a PIC, some of these operations can take thousands or tens of thousands of instruction cycles to execute because of the lack of direct hardware support of such math. If you start out doing assembly you'll quickly gain firsthand knowledge about what can and what cannot be done efficiently, and then later on when you are writing code in C you will always have a feeling for what is really going to happen when your code is compiled.

This is not to badmouth higher level languages at all... I use C pretty much exclusively on PICs, however I still don't recommend it as a first step. Even if you only spend a short while with assembly, do a handful of basic to intermediate projects (maybe work through a bunch of nigel's tutorials), it should benefit you.

Plus, if you ever have to get down to some short-duration precision delay routines (like if you're bit banging some sort of serial protocol) that can usually be done with more certainty in assembly, and many C compilers will allow you to use inline assembly code for this reason, among others, so that's yet another good reason to get a feel for it.
__________________
EEgeek.net
evandude is offline  
Old 7th December 2006, 09:11 PM   #6
Default

Hi,
Evandude's opinion is totally correct to my imagination. Higher level languages can be learnt later in due course.
__________________
Regards,
Sarma.
mvs sarma is offline  
Old 7th December 2006, 09:34 PM   #7
Default

I only use assembly.

I can't see any advantage in using a high level language for PICs.
__________________
Len
ljcox is offline  
Old 7th December 2006, 09:55 PM   #8
Default

Quote:
Originally Posted by ljcox
I only use assembly.

I can't see any advantage in using a high level language for PICs.
Depends on what you're doing. There's no way I'd attempt the USB interfacing stuff I've been doing lately with assembly, it would take me the rest of my life. And even for simple stuff, I can still throw together a program a lot faster in C than in assembly, and the written code is generally shorter and easier to read and follow than assembly. And, more and more C compilers are becoming compatible with MPLAB, so that you can do full simulation and C-source-level debugging directly in MPLAB, which makes them even more convenient for getting a project up and running more quickly. Not that I see anything wrong at all about spending plenty of time on projects, but the faster I can finish one, the faster I can start another, because my to-do list never ends!

But when I had to build a device that could transmit serial data at a rather high rate relative to the clock speed of the PIC (couple of dozen instruction cycles between output transitions) I didn't even think of using C, I went straight to assembly where I could control exactly how many clock cycles everything would take without worrying about the compiler making different optimizations and changing things. There's a time and a place for everything.
__________________
EEgeek.net

Last edited by evandude; 7th December 2006 at 09:58 PM.
evandude is offline  
Old 7th December 2006, 10:15 PM   #9
Default

Quote:
Originally Posted by ljcox
I only use assembly.

I can't see any advantage in using a high level language for PICs.
Perhaps your programs are not that complex.

Assembly produces efficient code using lots of man hours.

High level languages produce varying degrees of efficient code using far less man hours.

95% of industry could care less about code efficiency so long as the program works. 100% of industry wants to spend as few man hours as possible to complete a project because time is money.
phalanx is offline  
Old 7th December 2006, 11:25 PM   #10
Default

I think C: modular programming should be advantage for a large project.
__________________
Microcontroller Programming Forums:
http://forum.mcuprogramming.com
Answer to your questions!
---

Microcontroller Programming Blog:
http://mcu-programming.blogspot.com
uC - News, Resources and Tutorials
sci-3d is offline  
Old 8th December 2006, 08:32 AM   #11
Default thanks

thanks guys for your efforts,,,,,
i am using Assembly since two years and it is Great language,,,i really like it,,,but some people advised me to learn C for PIC programming..
thanks again
raedbenz is offline  
Old 8th December 2006, 02:48 PM   #12
Default

Quote:
Originally Posted by phalanx
Assembly produces efficient code using lots of man hours.
Providing you're good at it, sloppy asm code is often slower than C.
__________________

I do not answer private messages asking for help because no one else can: benefit from advice I may give or correct me if I'm wrong.

Please ask on the open forum if you have a question and I'll be happy to help,
if I know the answer.
Hero999 is offline  
Old 8th December 2006, 07:13 PM   #13
Default

Quote:
Originally Posted by Hero999
Providing you're good at it, sloppy asm code is often slower than C.
Very true. I was only posting best case scenarios.

Some C compilers are pretty efficient too. C30 for the dsPIC being one of them.
phalanx is offline  
Old 8th December 2006, 11:14 PM   #14
jjimenez101
Default

Yes I agree with alot of the comments made here on this subject. Assembly language does force you to learn the hardware aspect of microcontrollers. Such as registers, timers, stacks I/O ports and so forth. I have used assembly for many different types of projects and found it to be very easy to learn. Then, I moved on to c/c++, which I also enjoy to use. But assembly gave me the foundation on how to program logically and understand what exactly is going on behind the scenes in a micro-controller.
 
Old 9th December 2006, 03:25 PM   #15
Default

Try and learn assembly language, i.e. the language native to the device. Use assembly in small steps so you can understand the nuts and bolts of using the device then move on to higher level languages. This will stand you in good stead when debugging when using a higher level language, and will give you a deeper understanding of what's going on. My preference is for C, basic can be clunky and lead to bad programming practice. Having said that, basic is more like assembly language in terms of code structure so better chance of generating better assembly from basic. In the end there's no substitute for assembly in terms performance and space requirements, and I like to know exactly whats going on down there..!
saiello is offline  
Reply

Tags
language, programming

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Which Programming language?? pike Micro Controllers 5 8th December 2006 12:40 PM
PIC Programming in C Language onlineajit2000 Micro Controllers 21 8th July 2006 11:36 AM
Learning Assembly Programming Language Johnson777717 Micro Controllers 4 22nd March 2004 03:00 PM
which programming language ? hm_fa_da Micro Controllers 4 24th July 2003 10:55 PM
PIC Programming Language mailmicky24 Micro Controllers 1 12th March 2003 03:10 AM



All times are GMT. The time now is 06:03 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker