c programming

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
anyone able to help out finding a hand on approach to cprogramming designed around microcontroller programming?
I see the basics but I want something easy to follow if there is something like that
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
If I were you, I'd grab some book which concentrates on a particular device (PIC, Arduino, etc). Once you've learned how to handle one device, move along to another.

Some things will be similar, others will be very different. Trying to learn "generic" C for uC's is not really going to do more than confuse you (or be so general it's useless)
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
I agree with what Steve said, you really need to focus on a book for a particular micro family... Like any language the syntax will be fairly consistent but all the calls to whatever inside the chip will be different from chip to chip...

FYI I faced a similar dilemma when I was trying to get into micros (and it's part of my lingering issue in mastering C) every C book I found was a generic overview or computer based and half the stuff simply did not apply...

My biggest learning tool (with micros) was picking a compiler that had an active community and following user forums on a daily basis... I choose PicBasic Pro because of the fact I already knew BASIC and that saved me learning the basic syntax of say C, aka lazy by nature :) ... The support for the compiler as well as the 'BASIC stamp' that the compiler was modeled over was huge with PICs, at the time comparable to what you see for Arduino now...

Anyway I know you want C so follow Steve's advice, pic a chip, pick a compiler and read the forums... I'm betting that you will get a much better understanding from the forums then you will any single book on the subject...
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,271
Joined
Nov 17, 2011
Messages
14,271
What's your previous knowledge?
- Do you know "C" and want to extend C-programming to µCs??
- Do you know how to program a µC in Assembler and now want to go for "C"?
- Do you know anything about µCs at all?

While C is not a particularly difficult programming language, it has its quirks. It helps to become familiar with C first before starting to program a µC. Otherwise you may have to fight a battle along two frontlines: the programming language and the µC.
Or you do it the other way round.

A few noteable differences between C-programming on a PC or on a µC (I don't claim completeness of the list):
- On a PC you have access to powerful libraries. On a µC you usually try to keep the code small and libraries are often less powerful.
- On a µC you typically deal with lots of bitwise operations. Possible on a PC, but in my view uncommon.
- On a PC you usually have access to floating point arithmetic. Few µCs support this in hardware and the software solutions (libraries) are so much slower than pC hardware.
- On a µC size of code and data do matter very much more than on a PC
- ...

I suggest you first get acquainted with C using any of the free C compilers for PCs. Once you've mastered the basics of C go ahead and transfer that knowledge to programming a µC. For almost each type of µC you will find a community on the internet with sample code, sample circuits and lots of helpful information. Google "experiments with microcontrollers in C".
You may even ask here :D

I found this list of books which might befit your interest.

Another approach could be to look for a learning kit.

Harald
 

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
my programming skills were limited to BASIC ad they're bout 20 years rusted. so in other words my skills are nought.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,271
Joined
Nov 17, 2011
Messages
14,271
Here's a list of C prograrmming sites.

I really think you should grasp the basics of C before moving on to µCs. What's your prior knowledge of µCs?

Harald
 

dpenelob

Mar 27, 2013
15
Joined
Mar 27, 2013
Messages
15
If you just want to learn C, get Kerningham/Ritchie's "C Programming".
If you are able to write the sample programs given there, you might
eventually go on to µCs, since there you have to consider some more
aspects than on your PC (p.ex. input/output is certainly not possible
via printf/scanf as on the PC).
 

foTONICS

Sep 30, 2011
332
Joined
Sep 30, 2011
Messages
332
If I were you, I'd grab some book which concentrates on a particular device (PIC, Arduino, etc). Once you've learned how to handle one device, move along to another.

Some things will be similar, others will be very different. Trying to learn "generic" C for uC's is not really going to do more than confuse you (or be so general it's useless)

++++1 for this. Last summer I taught myself basic assembly programming for the PIC16f627a to prepare myself for the uController class I had coming up. We ended up using the HCS12 board which runs on a motorola and used the asmIDE which was COMPLETELY different than the .asm and MPLAB I was used to. The only thing I felt that learning a different family taught me was how memory was organized and how registers were manipulated.

I've wanted to get into arduino's and such but I want to become more comfortable with PICs before I start branching out
 

ads

Mar 4, 2013
6
Joined
Mar 4, 2013
Messages
6
I personally use mikroc it has many easy to use libraries. I all so recommend their development boards for value. there is more than enough information and example projects on their web site www.mikroe.com
 

ads

Mar 4, 2013
6
Joined
Mar 4, 2013
Messages
6
hi donkey how did you go with your research did you find a solution to that suits you
 

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
I am trying a few avenues but with work and kids finding time to sit down long enough to study is very hard
 
Top