This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

An introductory book to learn C for the 8051

I am reading "Patterns for time triggered embedded systems" of Michael J. Pont but I realized that I have a lack of C language knowledge. Could you please suggest me wich one among the two books listed below is the best choice?

- C and the 8051 Thomas Schultz

- Microcontroller projects in C for the
8051 family. Dogan Ibrahim

Thank you in advance

Francesco Fontana

  • my favorite is Kochan: Programming in ANSI C ISBN 0-672-48408-0

    Erik

  • I just bought the one of Thomas Shultz right yesterday night. Could you please tell me if yor favorite book is about ansi c only or ansi c for the 8051?

    Thank you

    Francesco Fontana

  • Kochan is about ANSI C for the PC.
    However, learning basic C on the '51 is an uphill battle. I suggest to everyone learn C on the PC, THEN start doing C on the '51.

    If you do your learning of the basics on the '51, you will, for every step have to compile, link, download, load HyperTerminal or whatever. On the PC click and see. The major difference between C on the '51 and PC C is I/O and that has nothing to do with learning C.

    Erik

  • "please tell me if yor favorite book is about ansi c only or ansi c for the 8051?"

    The ANSI 'C' language definition is entirely target-independent.

    Any target-dependent features will also be specific to a particular compiler, and the ANSI standard requires that the compiler provides documentation for these features.

    Hence I would agree with Erik: learn the language basics on a PC or similar first, then get to grips with the specific Keil (or whatever) implementation for the 8051 (or whatever).

    You didn't say whether you are already familiar with the 8051 itself?

  • "I am reading 'Patterns for time triggered embedded systems' of Michael J. Pont but I realized that I have a lack of C language knowledge."

    Have you read his other book, 'Embedded C':
    http://www.le.ac.uk/engineering/mjp9/embedc.html

    I haven't read it myself, but here's a review from the ACCU (Association of C & C++ Users):

    http://www.accu.org/cgi-bin/accu/rvout.cgi?from=0sb_embedded_systems&file=e003266a

    In particular, note the following in the 2nd paragraph:

    "...the title is not entirely representative of the book's content. 'Using the Keil C compiler for the 8051-series Microprocessor in Simple Embedded Devices' would be more descriptive of what is actually present."

  • re his other book, 'Embedded C':
    the brief spell out
    If you have some programming experience - in C, C++ or Java - then this book and its accompanying CD will help make your move to the embedded world as quick and painless as possible.

    Thus I do not know if this cover what the OP need

    Erik

  • If you think that "embedded C" of Mr.Pont is better of the "C and the 8051" of Thomas Shultz I would consider to buy this one too.
    The one of Thomas was reccomended by this
    web site in the book's list but actually In the amazon web site I saw only one review. I already bought the book anyway.
    I have a very good knowledge of Java, I am studing for an university degree exam about basic datastructures in Java. I studied in the past some C just for fun as I am doing with the 8051. But still I am not sure I know all what is needed to be confident with C.
    For Instance, memory allocation and pointers do not exist in java and I never understood the real purpose of the function "malloc". So you are probably right, a deeper understanding of C is useful but for that I have already a good book about ansi C to browse if needed.
    A normal C compiler by the way doesnt have a specific keyword to define which memory, internal external or the XRAM ( as I recently discovered in the p89c51) to use for the variables, or the sbit definition. For instance how can I know if the memory available on a standard 8051 is enough to calculate a sinus(). A normal high level language compiler assumes an almost endless memory so you never deal with these problems. Another concern, since as long as I understood C uses a software stack, is it necessary to use an external ram to run
    programs compiled in C ? what about recursion?. I don't want to waste your sometimes really precious time. I just wrote more to let you guess my level of knowledge of the topic.

    Thank you

    Francesco Fontana

  • For Instance, memory allocation and pointers do not exist in java and I never understood the real purpose of the function "malloc".
    For the '51 you do not need to. Malloc is one of the C features you should avoid when using the '51

    For instance how can I know if the memory available on a standard 8051 is enough to calculate a sinus(). A normal high level language compiler assumes an almost endless memory so you never deal with these problems.
    if there is not enough, you will get an error message. I suggest you get a SILabs f120 devkit ($149) that gives you "everything" (128k program memory, 8k data memory)

    Another concern, since as long as I understood C uses a software stack, is it necessary to use an external ram to run
    programs compiled in C ?

    Keil C does not pass parametres on the stack. If you need more than the standatd 256 bytes of DATA storage, instead of an external RAM, use one of the chips such as SILabs f12x, Pilips P89C668... that has "external RAM inside"

    what about recursion?.
    just avoid it, if you do it by mistake, you WILL get an error message. If you absolutotally, unconditionally, unavoidably need it there is the "reentrant" keyword.

    Erik

  • the SILabs devkits gives you ICElike capabilities which I would not like to be without were I to learn a new processor.

  • "A normal C compiler by the way doesnt have a specific keyword to define which memory, internal external or the XRAM ... since as long as I understood C uses a software stack, is it necessary to use an external ram to run programs compiled in C ? what about recursion?..."

    As I said earlier, all of this is compiler-specific stuff - so you will need to read the Manual for the specific compiler.

    The manual assumes that you already understand the 'C' language - that's why we suggest that you learn the language first, then the Keil specifics.