DSPRelated.com
Forums

Recommended Text For Embedded C/C++

Started by ger_lough October 19, 2009
Hi All

Just wondering if someone could suggest a popular text book for a newbie
to embedded C/C++? 
I read somewhere that Michael J Pont's "Embedded C" book is good. I also
came across "Embedded Systems Building Blocks: Complete and Ready-to-use
Modules in C" by Labrosse, Jean J, which looks good (especially since it
provides code examples. Don't know if Pont's book provides code examples?)
Suggestions much appreciated.

Thanks,
Ger.
ger_lough <debritb@tcd.ie> wrote:

>Just wondering if someone could suggest a popular text book for a newbie >to embedded C/C++?
Good question. Embedded C++ is not as popular as it should be. I know what language features I personally would leave out in any embedded code, so as to bring it up to the same efficiency level as C; maybe it's a simple enough exercise one does not need a special guidebook. Steve

ger_lough wrote:

> Hi All > > Just wondering if someone could suggest a popular text book for a newbie > to embedded C/C++?
I want to learn how to write poems. Can you suggest me a manual on using sharpie markers?
> I read somewhere that Michael J Pont's "Embedded C" book is good. I also > came across "Embedded Systems Building Blocks: Complete and Ready-to-use > Modules in C" by Labrosse, Jean J, which looks good (especially since it > provides code examples. Don't know if Pont's book provides code examples?) > Suggestions much appreciated.
Embedded C++ is just an organizer to keep your stuff in the convenient and manageable order. Think about the problem, avoid minor details of implementation until necessary. VLV
On Mon, 19 Oct 2009 12:30:53 -0500, "ger_lough" <debritb@tcd.ie> wrote:

>Hi All > >Just wondering if someone could suggest a popular text book for a newbie >to embedded C/C++? >I read somewhere that Michael J Pont's "Embedded C" book is good. I also >came across "Embedded Systems Building Blocks: Complete and Ready-to-use >Modules in C" by Labrosse, Jean J, which looks good (especially since it >provides code examples. Don't know if Pont's book provides code examples?) >Suggestions much appreciated.
The one that comes with the cross-compiler? Embedded C is just C, albeit typically in a freestanding (non-hosted) environment. Embedded C++ is an oxymoron (opinions may differ). Code examples are often either too general int uart_initialize(int baud) { // Your code goes here! } or too specific to a chip that you may never see int uart_initialize_for_DSP56F805_SCI(int baud) { ... followed by 283 lines of stuff you really don't care about } The best way to get started is just to dive right in. Get a dev kit that comes with a cross-compiler and examples, then make stuff happen. If you're bold, buy a couple of microcontrollers, a breadboard, and a compiler and have at it. Otherwise, something like the eBox-AVR <http://imagecraft.com/hardware_AVR-CAN.html> can make the transition a little less traumatic. -- Rich Webb Norfolk, VA
Rich Webb wrote:
> On Mon, 19 Oct 2009 12:30:53 -0500, "ger_lough" <debritb@tcd.ie> wrote: > >> Hi All >> >> Just wondering if someone could suggest a popular text book for a newbie >> to embedded C/C++? >> I read somewhere that Michael J Pont's "Embedded C" book is good. I also >> came across "Embedded Systems Building Blocks: Complete and Ready-to-use >> Modules in C" by Labrosse, Jean J, which looks good (especially since it >> provides code examples. Don't know if Pont's book provides code examples?) >> Suggestions much appreciated. > > The one that comes with the cross-compiler? Embedded C is just C, albeit > typically in a freestanding (non-hosted) environment. Embedded C++ is an > oxymoron (opinions may differ). > > Code examples are often either too general > > int uart_initialize(int baud) { > // Your code goes here! > } > > or too specific to a chip that you may never see > > int uart_initialize_for_DSP56F805_SCI(int baud) { > ... followed by 283 lines of stuff you really don't care about > } > > The best way to get started is just to dive right in. Get a dev kit that > comes with a cross-compiler and examples, then make stuff happen. If > you're bold, buy a couple of microcontrollers, a breadboard, and a > compiler and have at it. Otherwise, something like the eBox-AVR > <http://imagecraft.com/hardware_AVR-CAN.html> can make the transition a > little less traumatic.
Lets agree at the outset that I'm a fusty old fuddy-duddy. With any embedded project, the devil is in the details, and the fewer details there are, you are the less you are likely to be bedevilled. Start with a simple processor, one without an instruction pipeline, and learn its assembly language. (Z-80 Assembly Language Programming by Lance Leventhal might be a good start.) Then think PIC or a simple DSP board. HLLs are a tool for writing what you want. You have to know waht you want and how to get it before a HLL does you any good. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Mon, 19 Oct 2009 15:04:10 -0400, Jerry Avins wrote:

> Rich Webb wrote: >> On Mon, 19 Oct 2009 12:30:53 -0500, "ger_lough" <debritb@tcd.ie> wrote: >> >>> Hi All >>> >>> Just wondering if someone could suggest a popular text book for a >>> newbie to embedded C/C++? >>> I read somewhere that Michael J Pont's "Embedded C" book is good. I >>> also came across "Embedded Systems Building Blocks: Complete and >>> Ready-to-use Modules in C" by Labrosse, Jean J, which looks good >>> (especially since it provides code examples. Don't know if Pont's book >>> provides code examples?) Suggestions much appreciated. >> >> The one that comes with the cross-compiler? Embedded C is just C, >> albeit typically in a freestanding (non-hosted) environment. Embedded >> C++ is an oxymoron (opinions may differ). >> >> Code examples are often either too general >> >> int uart_initialize(int baud) { >> // Your code goes here! >> } >> >> or too specific to a chip that you may never see >> >> int uart_initialize_for_DSP56F805_SCI(int baud) { >> ... followed by 283 lines of stuff you really don't care about >> } >> >> The best way to get started is just to dive right in. Get a dev kit >> that comes with a cross-compiler and examples, then make stuff happen. >> If you're bold, buy a couple of microcontrollers, a breadboard, and a >> compiler and have at it. Otherwise, something like the eBox-AVR >> <http://imagecraft.com/hardware_AVR-CAN.html> can make the transition a >> little less traumatic. > > Lets agree at the outset that I'm a fusty old fuddy-duddy. With any > embedded project, the devil is in the details, and the fewer details > there are, you are the less you are likely to be bedevilled. Start with > a simple processor, one without an instruction pipeline, and learn its > assembly language. (Z-80 Assembly Language Programming by Lance > Leventhal might be a good start.) Then think PIC or a simple DSP board. > HLLs are a tool for writing what you want. You have to know waht you > want and how to get it before a HLL does you any good. > > Jerry
OTOH the OP may already know embedded, and embedded C, and is just looking for guidance on transitioning to C++. (Which, for large enough projects, _is_ a time-saver _if_ you bring the same level of discipline to the project as you should to any other software effort). -- www.wescottdesign.com
On Mon, 19 Oct 2009 12:30:53 -0500, ger_lough wrote:

> Hi All > > Just wondering if someone could suggest a popular text book for a newbie > to embedded C/C++? > I read somewhere that Michael J Pont's "Embedded C" book is good. I also > came across "Embedded Systems Building Blocks: Complete and Ready-to-use > Modules in C" by Labrosse, Jean J, which looks good (especially since it > provides code examples. Don't know if Pont's book provides code > examples?) Suggestions much appreciated. > > Thanks, > Ger.
Are you a newbie to embedded, or just to C++ in an embedded environment? What does "embedded" mean to you? How big is the project? If the former, I wouldn't suggest C++ as a vehicle to learning how to do embedded programming*. It _is_ (IMHO) the hands down favorite for handling a large project when you have gracious experts and eager junior hands. But if you're a lone junior hand who needs to fill 2kB of EEPROM with code, then C++ isn't the way to go. If the latter -- yes, there ought to be a book. I know that ESC magazine has a number of good articles on various aspects of doing good C++ programming in an embedded environment, and I suspect there are a few in Dr. Dobbs (although Dr. D has pretty much gone over to big box desktop stuff). * You may want to put me in a wheel chair next to Jerry, but if you haven't made something useful with assembly language in less than a kilobyte of code space then you probably don't have a firm foundation... -- www.wescottdesign.com
http://www.le.ac.uk/eg/mjp9/pes1ohp_a4.pdf


ger_lough wrote:

> Hi All > > Just wondering if someone could suggest a popular text book for a newbie > to embedded C/C++? > I read somewhere that Michael J Pont's "Embedded C" book is good. I also > came across "Embedded Systems Building Blocks: Complete and Ready-to-use > Modules in C" by Labrosse, Jean J, which looks good (especially since it > provides code examples. Don't know if Pont's book provides code examples?) > Suggestions much appreciated. > > Thanks, > Ger.
Vladimir Vassilevsky wrote:
> http://www.le.ac.uk/eg/mjp9/pes1ohp_a4.pdf
Caveat: the 8051 has some infelicities that make me hate it. Obvious instructions (like XOR) are missing, and although there is a data pointer register that can be incremented, there is no instruction to decrement it. While that may seem immaterial because the compiler takes care of the details, it can make it difficult to understand what the compiler is doing by reading the code it produces. There is a bug in the UART. It reloads as soon as the data bits have gone out, clobbering the stop bit. Unless 9-bit data is actually required, a work-around programs the device to send 9 bits. There is on;y one interrupt flag, shared between transmit and receive. If both processes are taking place simultaneously, the interrupt server has to figure out what needs service. ... Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins  <jya@ieee.org> wrote:

[8051]

> There is only one interrupt flag, shared between transmit > and receive. If both processes are taking place simultaneously, > the interrupt server has to figure out what needs service.
So who invented interrupt vectors anyway? They should give him, or her, a Nobel prize. Steve