you can test the first chapters and if you’re okay with it, order the printed version.
C von A bis Z (German)
von Jürgen Wolf’ date=’ Galileo Computing
ISBN 3-89842-643-2
OpenBook (!) oder gebundene Ausgabe: 39,90 €
Ein sehr gutes, plattformübergreifendes (!) und übersichtlich aufgebautes OpenBook. Kann man online ansehen, als zip herunterladen (html) oder gebunden bestellen, was will man mehr?
On a PC you have all kinds of standard libraries, for example <stdio.h> for in- and outputs, eg. reading the console-input with scanf() and using printf() to print chars to the console-output.
Of course these libraries are not available on the PIC, so you have only to learn the C-basics like: Syntax, Grammar, Data-Tyes, Functions, etc…
These topics are all handled quite well in this book. I found it’s one of the least confusing books regarding this issue compared to others
An exception to this roule is the SDCC-lib which was adapted for MIOS (required for multiplications and divisions), but it costs very much application space.
Well, if you are writing a MIOS app, then you use the MIOS functions to handle such things as ADC. If not, you would use the SDCC libraries or whatever libraries are available. The libraries or the OS will take care of the low level functions, so you just handle the variables.
That’s it. Basically. Every language has these basic syntax and grammar items; for objective oriented languages, there are some more things to learn, but with similar simple languages like C, PHP, JavaScript, Java, Perl… that’s it.
Once you got that, you can either:
write your own low level functions (that would be to re-invent the wheel)
or use existing low level functions (either in seperate files or bundled into libraries)
In theory it’s the same if you get your variable ‘i’ either from the console (with the stdin library):
[tt]sscanf(stdio, “%i”, i); // read input number from console[/tt]
or from a MIOS function:
[tt]i = MIOS_DIN_PinGet(pin); // read state of pin number[/tt]
see, it’s just a matter of reading the function reference, once you know where the “i”, the “=” and the “;” belongs.
So, to sum it up: Learning a language consists of three steps:
you have to learn and get the syntax!
you have to program by yourself. Don’t start with a huge IDE, just take a notepad (with the ability to compile the textfile, so you can learn on simple “one-filers”).
you have to know how to look up: if you can manage the syntax, you just have to learn how and where to look up function and library references. Nobody can ever remember a thousand functions, it’s normal to look these things up, so you don’t have to “learn” all this complicated stuff. The main syntax is enough, for the rest you can search your preferred documentation.
In theory it’s the same if you get your variable ‘i’ either from the console (with the stdin library):
[tt]sscanf(stdio, “%i”, i); // read input number from console[/tt]
or from a MIOS function:
[tt]i = MIOS_DIN_PinGet(pin); // read state of pin number[/tt]
Except that the first one is passing an int instead of a pointer to an int and will stop your program with a segmentation fault if you’re lucky and overwrite random parts of memory if you’re not.
I definately agree with the idea of learning C on a PC first. There you have memory protection to stop errors like this (especially if you use a library like dmalloc) and much better debuggers. On the PIC you will just get your program behaving strangely and probably not even in the place that is causing the error. I once allocated an array 1 element too short and didn’t notice. Then program started crashing when i added more code, regardless of what the code was or where i added it.
What I like about it (besides the price) is that it’s very clear structured and contains line-by-line explained examples for every entry; that makes it a valueable book not only to learn but also to look up things later.