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 9th December 2006, 03:57 PM   #16
Default

There is no right answer here. A lot depends on the individual. Personally, knowing and using both asm and C is the best end result.

You can understand the structures of a microcontroller with out learning ASM. Except for precise short delays, you can pretty much do everything in C. I've programmed all the features of the midrange in C.

The advantage of C is that much of program house-keeping is done for you. banks, pages, pclath, bit-test-skip-double-inversion jumps, flash rom tables, ... can be error prone for even experienced programmer in asm. Still, the ability to read and understand asm is important as many examples are written in asm.
philba is offline  
Old 9th December 2006, 04:58 PM   #17
Default

Quote:
Originally Posted by philba
You can understand the structures of a microcontroller with out learning ASM.
You can, but a good method of learning it is to learn assembler - it's probably counter productive to try and learn the underlying hardware without also learning assembler.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 9th December 2006, 06:59 PM   #18
Default

Quote:
Originally Posted by Nigel Goodwin
You can, but a good method of learning it is to learn assembler - it's probably counter productive to try and learn the underlying hardware without also learning assembler.
I respectfully diagree with you. there is no one correct answer. You can access all the underlying architecture in C just as easily as in asm. it's a perfectly valid way to go. In some ways, it's more productive for a beginner because they don't have to deal with things like banks, pages, skip flow of control, etc.

Note that I am not saying asm is an incorrect approach. It's perfectly fine, too.
philba is offline  
Old 10th December 2006, 05:42 PM   #19
Default

Quote:
Originally Posted by philba
I respectfully diagree with you. there is no one correct answer. You can access all the underlying architecture in C just as easily as in asm. it's a perfectly valid way to go. In some ways, it's more productive for a beginner because they don't have to deal with things like banks, pages, skip flow of control, etc.

Note that I am not saying asm is an incorrect approach. It's perfectly fine, too.
You appear to be missing the point?, it's not about the language, it's about the underlying hardware - assembler forces you to understand the hardware, C doesn't, and it makes it difficult to program effectively without that knowledge.

Fine, you could study the hardware and understand it from a C point of view, but I would suggest that is more difficult than learning a small amount of assembler in the first place?.

You see some absolutely horrible code written in C and BASIC, simply because the writers don't have a clue about the hardware.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 10th December 2006, 05:54 PM   #20
Default

Hi all
Are we making a case out of nothing- these are inter complimentary.any one writing a prog has his own comfort or discomfort and many times feels homely with what one knows. Volumes can be written with 'C' by them comfortably as it saves mental fatigue. Let us imagine software written for Various Telecom digital switches with parallel processing depended on 'C' language.

while writing for a microcontroller, if one feels comfortable with what one Knows, let him . Hope we should put stop to this and start delivering effective software.

towards this end the site managers can organise a sort of heathy compitition across a critical pproject. we need not bother aBOUT TIME TAKEN AT THIS STAGE, BUT ONLY TRY JUDGING THE SIMPLICITY AND TIME TO PERFORM THE WANTED FUNCTIONS. EACH PARTICIPENT SHALL HANDOVER THE SOURCE CODE TO THE PANEL AND THE SITE COUL GET THEM EVALUATED BY DISPASSIONATE PANEL.

Let us take it spotive. Incidentally it can also involve hardware and PCB design interested groupswho will first do it and others to write software top work for the end goal.

i have suggested these with no bias as i am neither a software (C<BASIC< PASCAL<ASSEMBLY< FLOWCODE< JAL and what not)or hardware professional and regard all teams as eminent in their fields-
__________________
Regards,
Sarma.

Last edited by mvs sarma; 10th December 2006 at 06:02 PM.
mvs sarma is online now  
Old 10th December 2006, 06:36 PM   #21
Default

If you feel comfortable writing in 'C' and things work for you then fine. If you're happier writing in assembler then that's fine too, there is no actual right or wrong way to do things. What has to be borne in mind though is that they are complimentary approaches and that each has it's pros and cons. 'C', Basic or any high level language allows for a 'black-box' approach to driving machines which means you can be more productive and also allows you to work cross-platform. Assembler, although tied to a particular machine or device which means having to learn the instructions peculiar to that machine, allows you to have a clearer understanding of the underlying hardware and gives you the opportunity to write the most efficient code. It's when problems arise that the assembler coder has the upper hand and has a better chance of locating the source of any problem. The 'C' coder has less of a chance because he/she is necessarily 'shielded' from the nuts and bolts. Even of you insisted that you only wanted to write in 'C', it would be of great benefit to at least have some understanding of assembler not only because it can help to locate sources of problems but allow you to write more efficient 'C'. It goes without saying that a full understanding of both is the best scenario!
saiello is offline  
Old 10th December 2006, 11:51 PM   #22
Default

Quote:
Originally Posted by Nigel Goodwin
You appear to be missing the point?, it's not about the language, it's about the underlying hardware - assembler forces you to understand the hardware, C doesn't, and it makes it difficult to program effectively without that knowledge.

Fine, you could study the hardware and understand it from a C point of view, but I would suggest that is more difficult than learning a small amount of assembler in the first place?.

You see some absolutely horrible code written in C and BASIC, simply because the writers don't have a clue about the hardware.
No, I am not missing the point. C doesn't prevent you from learning the important features of the chip and it is, in many ways, easier to learn it with C because you can focus on just the specific feature rather than all the stumbling blocks of PIC architecture. You can just as easily learn PWM, capture compare, timers, ADCs and so on.

Had you said, you can (learn to) write more efficient code in asm, I would wholeheartedly agree. especially when a program overflows a bank and/or a page.

I don't think pointing to bad code is a reasonable justification. I've seen plenty of horrible assembler, too. bad programmers write bad code, not compilers. One could also point out that assembler coding is much more error prone. I taught both C and assembler at the college level and found that more people had problems writing decent assembler than any other language, by far.

And, I will continue to point out that people should really know both languages as a good engineer uses all the tool available.
philba is offline  
Old 11th December 2006, 02:48 AM   #23
Default

I agree with phil. When I first started with microcontrollers it was a bit of a chore and confusing to program in assembly.

Then I found JAL, which is a high-level language, but lets me insert assembly wherever I want. Now I have a much better understanding for the underlying hardware. I would have been discouraged had I not accomplished things first with a high-level language (which I still use).

And, afterall, isn't this the whole point of the Basic Stamp, PICAXE, etc.?

It's probably counterproductive to try to learn the hardware AND assembly at the same time. It can be too much at once.

Mike
upand_at_them is offline  
Old 11th December 2006, 05:10 AM   #24
Default

Quote:
Originally Posted by saiello
If you feel comfortable writing in 'C' and things work for you then fine. ........................... Even of you insisted that you only wanted to write in 'C', it would be of great benefit to at least have some understanding of assembler not only because it can help to locate sources of problems but allow you to write more efficient 'C'. It goes without saying that a full understanding of both is the best scenario!
Hi,
i said i am intersted to learn 'C'. if you see the next sentence there in my post, you understand my mind. i do agree i am a ZERO in any language and trying to learn to have a hobby at 61+. i didn't want to discourage the person reg C but he/she should have an understanding of Assy as it is a practice to use Assy patches at places so far. Off late , due to reduction of prices and large chunks of memory embedded into controllers, one feels comfortable with HLL. ...
__________________
Regards,
Sarma.
mvs sarma is online now  
Old 11th December 2006, 09:46 AM   #25
Default

Quote:
Originally Posted by philba
No, I am not missing the point. C doesn't prevent you from learning the important features of the chip and it is, in many ways, easier to learn it with C because you can focus on just the specific feature rather than all the stumbling blocks of PIC architecture. You can just as easily learn PWM, capture compare, timers, ADCs and so on.
As I've said all along, you need to understand the hardware, assembly forces this on you - C doesn't. As long as a C programmer studies and fully understands the hardware, everything is perfectly fine - but generally they don't bother (probably because of PC programming where it's not very often needed, and in fact discouraged).

It's probably as easy (if not easier?) to learn the hardware by a brief study of assembler, which only has 35 instructions (most of which you don't need to know about to understand the hardware).

The datasheets don't explain the hardware using C, and there's a generally lack of sample C code and books - a good C tutorial, giving condensed datasheets using C examples would do just as well - but does such a thing exist?.

Quote:

And, I will continue to point out that people should really know both languages as a good engineer uses all the tool available.
No problem, I fully agree, it's just the lack of understanding of the hardware which I see as a problem.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 11th December 2006, 03:44 PM   #26
Default

Well, clearly, we disagree that asm is the only way to do it. There is never just a single path to knowledge.
philba is offline  
Old 11th December 2006, 04:18 PM   #27
Default

Quote:
Originally Posted by philba
Well, clearly, we disagree that asm is the only way to do it.
Not really, because I've never said that! - I've said (repeatedly) that you need an understanding of the hardware to program a PIC effectively in C - and that an easy way to get this understanding is a little knowledge of assembler.

As the datasheets are in assembler, as are almost all the application notes, it makes sense to have enough assembler knowledge to convert the required hardware understanding to C. If the information was available in C, then you wouldn't need to.

Incidently I did a 'similar' thing many years ago - converting C programs to Pascal - I learnt enough C to understand how to convert the programs, something I couldn't do with zero knowledge of C.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 11th December 2006, 04:51 PM   #28
Default

I'm not sure your statement above jibes with this earlier one:
Quote:
As I've said all along, you need to understand the hardware, assembly forces this on you - C doesn't.
I think the key factor is the individual, not the language. A focused student can use either plus the datasheet to learn the features of the chip. I see nothing in the C language that makes it harder and like I said earlier, there is a clear case for it being easier in C.
philba is offline  
Old 11th December 2006, 05:49 PM   #29
Default

Quote:
Originally Posted by philba
A focused student can use either plus the datasheet to learn the features of the chip.
And I think we can all agree that on average, this forum tends to attract a lot of not-so-focused students. Since this entire argument stems from people making recommendations to an inexperienced individual who wanted advice on a good programming language to get started with. It's hard to disagree that ASM forces you to get familiar with the hardware, whereas in C the language doesn't force it on you, so it's up to you to take it upon yourself to learn it. You're totally right that a dedicated person should have no trouble learning the architecture while using C, but that's not for everyone.

Since we don't personally know the capability or learning habits of every single person who asks for advice on getting started programming microcontrollers, I still stick with Nigel in saying that is probably a better bet to recommend ASM before C, simply because it's more of a sure bet.

If I had a friend who I'd known for years, and I was familiar with his programming ability and knowledge of computer architecture and stuff like that, then I would be much more inclined to advise them to go straight to C... But the people who ask for this sort of advice on a daily basis can really run the gamut from high school kids with no electronics or programming experience, to college kids with a good background in programming and computer architecture, or beyond... and you have to admit, they usually don't give any good indication of their abilities.
__________________
EEgeek.net

Last edited by evandude; 11th December 2006 at 05:58 PM.
evandude is offline  
Old 12th December 2006, 01:17 PM   #30
Default

Bah! I code my AVR's in Bascom Basic. I purchase the appropriate chips for my tasks by reviewing datasheets to understand the abilities they provide. I have as much need to understand every last detail of the chips operation as I do in understanding the complexities of pentium cpus when I code for pc. As long as the result is functioning code that does what is intended, so be it.

My priorities are easy to understand code that can be readily modified if need be (especially some time after initial programming, when the code is no longer fresh in the mind), and time investment on project construction and overall 'debugging' limits the time available for coding. Perhaps your guys projects are much more complex than mine, but I've not run into anything so far that required effeciency beyond what Basic has to offer; either in speed or size. This includes projects with lcd, i2c, spi, adc, multi channel pwm, etc. that can typically be accomplished in a very short period of time, thanks to the power of the programming functions available.

I recently finished a vector generator project for oscope display that required a lot of geometry and fractional math... I could not imagine coding this in assembly; I had the foundation of my project running within an hour. I'm not sure any benefits I would have gained in understanding the chip's hardware functioning in calculating such mathematical fuinctions would have outweighed the time and energy invested in learning and debugging them at assembly level.

Also, microcontrollers, like many other digital devices, are becoming larger and faster all the time. I expect that in the near future, coding microcontrollers in assembly will be as prevelant as assembly in pc programming is now - virtually gone.

Of course, this is simply my opinion ;-)

Last edited by agent420; 12th December 2006 at 01:25 PM.
agent420 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 07:45 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker