Using C to program the 8051 family

Jan 01, 2004 149 Replies

Hi,



I've been developing some 8051 based projects and the programming is getting a bit taxing in assembly language.



I'm a bit familiar with C and was thinking of using that to program the uC.



Does anyone have any good websites where I can find some in depth information on starting off programming the 8051 in C?



Thanks a lot.


- Al


formatting link
is a good starting place. They have an obvious interest in selling you a compiler, but there are lots of technical notes and example code. It's a very useful site.

If you're interested in a free compiler, you should take a look at . Even if you're not interested in the compiler, the links page has a lot of good things.

Grant Edwards grante Yow! We are now enjoying at total mutual interaction in visi.com an imaginary hot tub...

In article , Aliasger writes

It depends on who's 51 you are using and what sort of applications you do.

formatting link
C51 Primer, C traps and pitfalls, embedded debugging and other papers papers.

formatting link
is also very good.

Compilers:-

formatting link
formatting link
formatting link

Depending on your the Mcu you are using the manufacturers web site is a good place to start.

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\ /\/\/ snipped-for-privacy@phaedsys.org

formatting link
\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Start at

formatting link
do a little searching, also google is good at searches. You might try different variations with 8051,8052,

8031, howto and C compiler. Use the advanced search to limit the information. Also do a goole seach on the newsgroup (and probably a few others) as it may turn up a few intersting links.

formatting link
formatting link

The above maybe a little helpful. The grey'd out links on the HCS page are things I'm working on. The links work but the articles are a work in progress so pardon the grammer and spelling, I'm no where near done. I tend to rip, tear and throw free thoughts on a page. I wouldn't mind either emailing me or a reply here to anything you might find that is useful.

Linux Home Automation Neil Cherry ncherry@comcast.net http://home.comcast.net/~ncherry/ (Text only) http://linuxha.sourceforge.net/ (SourceForge) http://hcs.sourceforge.net/ (HCS II)

If you had followed this newsgroup for even a few days you would have found a healthy discussions of the pros and cons, costs and limitations of the SDCC and Keil compilers and availability thereof.

Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net) Available for consulting/temporary embedded and systems. USE worldnet address!

Hi, I would think again, switching to another language won't make your problems dissapear you just get some new ones. If C is the right chioce for your project then the 8051 is allmost certainly not the right processor.

problems

project

I disagree.

Taking the second point first: C is absolutely fine for an 8051. Ideal, even.

The first point has an element of truth. If the problems are not related to code management (e.g. it's the wrong platform for the job regardless of language), then you're right - C won't help.

But often the "problems" with large assembler projects come down to an underlying lack of structure or organisation. Mastering C (which can take a while - I'd agree it's certainly not an instant magic bullet for a newcomer)

*should* help with gaining a means of adopting good structuring - i.e. good, modern design practice.

OTOH, I've seen some right pigs ears written in C - for any platform. To the OP: I frequently use C as a means of designing code, and then either hand- or machine-compile from there. The discipline that modern object-oriented C encourages, e.g. active control of scope of variables, is hugely helpful even in assembler - even if assembler doesn't demand it.

HTH,

Steve

formatting link

Why do you say that? A _lot_ of people (including some I know) have done an awful lot of 8051 projects in C. They seem quite happy with the results.

Grant Edwards grante Yow! If I felt any more at SOPHISTICATED I would DIE visi.com of EMBARRASSMENT!

use Google and search for "final word on the 8051", you will find an online pdf file that should be quite helpful. (it assumes you are using the Keil compiler but is useful even if you use another one)

Mark

I've done quite a few 8051 projects in C and those products were quite well received and very cost-effective.

Casey

Hi, I have yet to see a project written in C where the 8051 was the best choice on either performance or price. C is to the 8051 what windows is to a pentium. Of course is your poduct doesn't need much performance then allmost anything would do.

snipped-for-privacy@aol.com (CBarn24050) wrote in news: snipped-for-privacy@mb-m29.aol.com:

I have yet to see one that wasn't. What kind of statement is that you are making? The 8051 is dog-simple to program, supplied by an unbelievable array of companies, has *excellent* C compilers available, wonderful peripheral choices, the core can be placed into an FPGA for SoC designs, Cygnal has JTAG debuggable version that run 12x the clock efficiency of the original 8051, you can use off-chip CODE and XDATA space if needed, fast interrupt context switching using register banks, etc. etc.

- Mark -> --

I guess you belong to the "Real Programmers use COPY CON PROGRAM.EXE" school of programming?

The choice between C and assembly isn't anything like as simple as you make out, and "performance" is measured in different ways. For almost any nontrivial piece of code where you're not actually down to the cycle-counting level of time criticality, the [potential] portability and [potential] productivity gains of using C are a strong argument against assembler - even in 8-bit platforms.

In article , CBarn24050 writes

Are you sure you are in the right NG? This one is embedded...

I think only 5% of 8051 programmers still use assembler only. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\ /\/\/ snipped-for-privacy@phaedsys.org

formatting link
\/\/ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

He is beginning to sound like a troll to me.

Ian

"CBarn24050" pontificated in message news: snipped-for-privacy@mb-m29.aol.com...

choice

pentium.

anything

It seems to me you have never developed any projects using the 8051 and C language, or just aren't very good at it.

I don't know if the rest of the original post made any sense, but this statement on its own is ridiculous.

Bob

Hi, I did once try with the 2500 compiler but it was hopeless, once I went back to assembler it all worked out fine.

Hi Bob, can you actually justify that remark? Got any actual numbers from real applications?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required