Using C to program the 8051 family - Page 4

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Re: Using C to program the 8051 family

Quoted text here. Click to load it
snip


Unfortunately Ansi C compliance does not help when switching micro platform
as all the important stuff like interrupts, timers, peripherals etc are all
different.

Ian


Re: Using C to program the 8051 family
Albert Lee Mitchell said...

Quoted text here. Click to load it

I guess I've been dreaming for the last 10 years then.  Shipped at
least fifteen products and never used an ICE.


Casey

Re: Using C to program the 8051 family

Quoted text here. Click to load it

Almost likewise.

Mike Harding


Re: Using C to program the 8051 family
Quoted text here. Click to load it

I can push that time span to 30+ years.  I will concede that once
or twice I have wished for one.

--
Chuck F ( snipped-for-privacy@yahoo.com) ( snipped-for-privacy@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
We've slightly trimmed the long signature. Click to see the full one.
Re: Using C to program the 8051 family
CBFalconer said...
Quoted text here. Click to load it

I'll concede that point as well.  There were a few times.


Casey

Re: Using C to program the 8051 family

Quoted text here. Click to load it

This is interesting. I've never thought about it before, but I've done
dozens of microcontroller based projects and I've never used an ICE either.

Bob

Re: Using C to program the 8051 family

Quoted text here. Click to load it

Debug stub and a serial port.  I'm doing it right now on an
H8: burn gdb stub in to flash, and away you go.  Downloading is
a bit slower than traditional ICE, but it works quite well.

Quoted text here. Click to load it

See above.

--
Grant Edwards                   grante             Yow!  Intra-mural sports
                                  at               results are filtering
We've slightly trimmed the long signature. Click to see the full one.
Re: Using C to program the 8051 family

Quoted text here. Click to load it

I debug C the same way I debug assembler or anything else. By writing debug
code. I also like to generate "life noises" like toggling a port bit on
entry to an ISR saying " I made it this far", also squirting out diagnostic
messages to a serial port.

Bob

Re: Using C to program the 8051 family
Bob Stephens said...

Quoted text here. Click to load it

I like to toggle test points and watch those on an oscilloscope.  
I monitor events and the duration of interrupt routines this way.


Casey

Re: Using C to program the 8051 family

Quoted text here. Click to load it

    That's not unsimilar to our methodology except we use the same code as
the finished job will, not test code.  Using the serial port for
diagnostic messages has a major impact on execution speed which I very
much wish to avoid.

    Without running the same code at the same speed you're not really
exercising the final product.
 
-- Regards, Albert
----------------------------------------------------------------------
AM Research, Inc.                  The Embedded Systems Experts
http://www.amresearch.com 916.780.7623
----------------------------------------------------------------------


Re: Using C to program the 8051 family

Quoted text here. Click to load it

Yes I agree. I was talking about debugging in the very preliminary stages
where you're not even sure if the oscillator is clocking the chip properly.

Bob

Re: Using C to program the 8051 family
On Sat, 3 Jan 2004 21:14:57 +0100, "Klaus Vestergaard Kragelund"

[...]
Quoted text here. Click to load it

I'm not the one you asked, but I didn't see where anyone really
answered this question...

C is totally, completely, and utterly usuited for the 8051.  Or any
other 8-bit micro.  And vice-versa.  (Well, the AVR isn't too bad, but
that's a special case: it was developed with the help of a compiler
vendor specifically to work nicely with C.)

1) C assumes 16 (or more) bit calculations are efficient.  The "int"
type is supposed to have the width "natural" to the processor, but
must be at least 16 bits wide.  There is _no_ way in C to to write an
uncast expression containing at least one operator whose result is
either {[un]signed] short or [[un]signed] char.

2) C assumes minimum resources are available.  For example, there must
be a minimum of 511 identifiers allowed within a block scope.  And 127
parameters to a function.  And 4095 characters in a string literal.
and 1023 members in a structure.  Try that with 128 bytes of data RAM.

3) Functions must be able to be called recursively, including main.

4) C has no concept of separate memory spaces, let alone separate RAM
spaces (data, idata, xdata).  This is bad enough on a von Neumann
architecture, but on a Harvard micro (like the 8051) it's devastating.

This is off the top of my head.  I'm sure there are others.  

The 8051 seems to have been fiendishly designed to make programming in
C difficult, inefficient or just impossible.  Some of the worst
problems are the lack of stack space, access of xdata through dptr
only, and of course, the Harvard architecture.  The only chip that
seems to be worse (disregarding 4-bitters) is the 12- and 14-bit PIC
cores (I haven't looked closely at the 16-bit PIC core or the dsPIC
yet).

OTOH, Keil (and some of the other vendors and perhaps SDCC as well)
has generally done an excellent job with its NQC (Not Quite C)
development systems.  They're very effective and easy to use, and make
efficient use of the 8051 resources.

Just don't go confusing them with C.

Regards,

                               -=Dave
--
Change is inevitable, progress is not.

Re: Using C to program the 8051 family
Quite so Dave but your comments will fall on deaf ears here.

Re: Using C to program the 8051 family
Quoted text here. Click to load it

    Thanks for adding some more recent experience, Dave, mine is woefully out
of date and I'd forgotten a few of those glitches.  C was written for
Unix, not for 8-bit micros.  Although time has extended C to other venues
and added new features it remains unsuited for the 8051.

    One point, I know you were joking but the 8051 was first designed about
1975 with no thought to C.  I think the languages of the day were first
Assembler (duh), PLI, then Basic.
 
-- Regards, Albert
----------------------------------------------------------------------
AM Research, Inc.                  The Embedded Systems Experts
http://www.amresearch.com 916.780.7623
----------------------------------------------------------------------


Re: Using C to program the 8051 family

Quoted text here. Click to load it

In 1975 nearly all embedded programming was being done in
assembly language, with FORTRAN and PL/M to follow. There were
some fairly compact BASIC interpreters; but their performance was
generally 'poor' to 'intolerable' for time-critical applications.

I used C on (first) I8080 and (later) Z80 CPUs and had no serious
problems - though I was constrained to integer math. Even the
primitive 8080 could be programmed to produce 32-bit (or larger)
results when needed.

I've never needed to produce code for an 8051 (nearly all of my
more recent work has been on 16- and 32-bit SOCs) but I'm amazed
to hear that the 8051 has less capability that Intel's old I8080
or Zilog's Z80!

--
Morris Dovey
West Des Moines, Iowa USA
We've slightly trimmed the long signature. Click to see the full one.
Re: Using C to program the 8051 family

Quoted text here. Click to load it

Why?  The 8051 (and it's predecessor the 8048) was aimed at
much smaller, simpler applications than the 8080/Z80 family.

IIRC, the 8048/8051 were built for Ford.  They were intended
for very small, simple automotive control applications with a
few KB of code and maybe 50-100 bytes of RAM.  The 8080/Z80 was
a much more "powerful" general-pupose CPU with a stack pointer,
16-bit operations, and everything.

--
Grant Edwards                   grante             Yow!  What I want to find
                                  at               out is -- do parrots know
We've slightly trimmed the long signature. Click to see the full one.
Re: Using C to program the 8051 family

Quoted text here. Click to load it

The archtypical application for an 8048 in those
days was a keyboard controller.  I believe the
original IBM PC keyboard used one.




Re: Using C to program the 8051 family
On Tue, 06 Jan 2004 11:52:08 -0800, the renowned Jim Stewart

Quoted text here. Click to load it

That was a variant (8042 or something like that).

Best regards,
Spehro Pefhany
--
"it's the network..."                          "The Journey is the reward"
snipped-for-privacy@interlog.com             Info for manufacturers: http://www.trexon.com
We've slightly trimmed the long signature. Click to see the full one.
Re: Using C to program the 8051 family

Quoted text here. Click to load it

Was?  What do they use now?

Ian


Re: Using C to program the 8051 family

Quoted text here. Click to load it

The *was* refers to the *archtypical application*
and was not meant to infer that it is no longer
used in IBM PC keyboards.

It's been a few years since I've disassembled an
IBM keyboard and I don't rightly know what kind
of controller it uses.





Site Timeline