Author Topic: c language sample codes and Book  (Read 6574 times)

0 Members and 1 Guest are viewing this topic.

Offline ect_09Topic starter

  • Contributor
  • Posts: 17
c language sample codes and Book
« on: October 21, 2014, 07:25:44 am »
am looking for the sample code and book where i can learn the C language for micro controller.
please give me suggestion. :scared:

Regards,
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6459
  • Country: nl
Re: c language sample codes and Book
« Reply #1 on: October 21, 2014, 07:46:33 am »
Do you know c? If not start with The c handbook  from Kernighan and Richie.
Then choose an application book for your specific microcontroller and last start doing exercises and make mistakes since those are the only ones you really will learn from  ;)
 

jucole

  • Guest
 

Offline Kostas

  • Regular Contributor
  • *
  • Posts: 71
  • Country: gr
Re: c language sample codes and Book
« Reply #3 on: October 21, 2014, 07:47:57 am »
There is no such thing as C language for microcontollers. There is the C programming language and there are endless libraries that can be used in C code. The registers and peripherals of a uC have nothing to do with the language itself, but a manufacturer, or third party, might supply a library that can be used to write code for a specific uC. So, IMHO, you'd  better get a generic book about C and learn the language. The rest is uC specific stuff that differs between vendors and uCs. The classic book about C is "The C programming language".
« Last Edit: October 21, 2014, 08:28:39 am by Kostas »
 

Offline true

  • Frequent Contributor
  • **
  • Posts: 329
  • Country: us
  • INTERNET
Re: c language sample codes and Book
« Reply #4 on: October 21, 2014, 09:00:05 am »
Kostas, there seems to be an obvious language barrier, but that aside, it is a bit ingenious to say that. Yes, there isn't "C for micros," but embedded or constrained system development is a lot different from desktop or user-interactive development normally seen today. "The rest (of the) uC specific stuff," as applied with the language, is exactly what ect_09 is trying to learn.
 

Offline con-f-use

  • Supporter
  • ****
  • Posts: 807
  • Country: at
Re: c language sample codes and Book
« Reply #5 on: October 21, 2014, 11:53:54 am »
"The C Programming Language" has become a little old these days. Having taught C classes at two universities, I'd recommend K. N. King's book "C Programming: A Modern Approach".

Microcontrollers specific books depend on what uCs by what vendor you want to program, I'd agree with Kostas.
 

Offline Palmitoxico

  • Regular Contributor
  • *
  • Posts: 55
  • Country: br
  • no
Re: c language sample codes and Book
« Reply #6 on: October 21, 2014, 03:08:06 pm »
The major differences between microcontroller development and computer programs development in C is that you have a very limited memory (RAM and ROM) and you normally have to deal with microcontroller's specific registers.

Some hints for embedded programming:
- Try to avoid dynamic memory allocation (malloc & free);
- It's common to find microcontrollers with less than 1Kbytes RAM;
- Your stack is really small (16~256 bytes for most 8-bit microcontrollers), avoid declaring large arrays of data inside functions;
- Only powerful microcontrollers have floating point units, so prefer use fixed point math or your binary will get large and slow;
- Standard C functions like printf and scanf aren't always implemented on some microcontroller's libraries, and when they are you need additional configuration before use.

Buy some dev board from atmel or microchip and start writing some code!
 

Online zapta

  • Super Contributor
  • ***
  • Posts: 6189
  • Country: us
Re: c language sample codes and Book
« Reply #7 on: October 21, 2014, 05:09:16 pm »
For samples just look at Arduino examples. They are mostly C with a few C++ extensions.
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: c language sample codes and Book
« Reply #8 on: October 21, 2014, 06:09:13 pm »
I like O'Reilly's Practical C Programming.  That's how I learned.  I recommend starting on a PC, as there's enough to learn as it is.  Get through the book and try some of the programming challenges to become comfortable with C.

Then, pick up an Arduino.  It's a great way to get started with digital electronics, and micros in particular.  The IDE is really simple, but awful once you get to projects of any substantial size.  Use it until you start running into its limitations, then learn to use Atmel Studio instead.

By that point, you're no longer a noob, just an inexperienced embedded developer.  So follow your whims and practice practice practice.  Branch out to other vendors and platforms as you feel inclined to do so.  The rest of the journey isn't in a book, it just takes time.
 

Offline the_memristor

  • Newbie
  • Posts: 7
  • Country: de
Re: c language sample codes and Book
« Reply #9 on: October 23, 2014, 05:43:34 am »
Take a look at this: https://www.eevblog.com/forum/microcontrollers/embedded-programming-mooc-to-be-re-offered/
The mentioned course is for free and offers a good entry to beginner!
 

Offline ect_09Topic starter

  • Contributor
  • Posts: 17
Re: c language sample codes and Book
« Reply #10 on: October 28, 2014, 11:17:34 am »
Thanks
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: c language sample codes and Book
« Reply #11 on: November 09, 2014, 10:19:14 pm »
I don't know for a book, but for microcontroller programing aspect, you can find good things on newbiehack.com
 

Offline 22swg

  • Frequent Contributor
  • **
  • Posts: 274
  • Country: gb
Re: c language sample codes and Book
« Reply #12 on: November 10, 2014, 10:14:24 am »
C and micro book together are not really necessary or ideal as they will be micro specific . if you have micro assembler experience then you are half way there , I found "C for Dummies 6 in 1 " by Dan Gookin easy to understand he also has sample files on a website , easy to find mcu specific examples on the web to paste and modify and learn at the same time. You will need a platform to test your results, a simple breadboard setup will do.  ( and i didn't mention a single micro company  8)
« Last Edit: November 10, 2014, 01:07:20 pm by 22swg »
Check your tongue, your belly and your lust. Better to enjoy someone else’s madness.
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: c language sample codes and Book
« Reply #13 on: November 10, 2014, 02:13:19 pm »
Basically all that applies for microcontrollers is basic logic operators, math, if then , for loops, arrays and variables. All the PC style outputs don't work on the MCU.
The larger the government, the smaller the citizen.
 

Online mikerj

  • Super Contributor
  • ***
  • Posts: 3233
  • Country: gb
Re: c language sample codes and Book
« Reply #14 on: November 11, 2014, 07:29:57 pm »
Basically all that applies for microcontrollers is basic logic operators, math, if then , for loops, arrays and variables. All the PC style outputs don't work on the MCU.

Not quite true, you can use formatted I/O and file streams etc. if you have the hardware and don't mind the overheads.
 

Offline FPGAcrazy

  • Contributor
  • Posts: 17
Re: c language sample codes and Book
« Reply #15 on: November 11, 2014, 07:54:58 pm »
Hi,

Sorry, I do not know any good books. But one thing I see coming back is the K&R book "The C Programming Language". It is adviced by many people here to beginners in C.
I like to point out that this book is really difficult to start with.   |O I program C for almost 20 years and like it as a language reference.   :-+ But for beginners this is really a terrible book.  :--
It is great when you use it as a reference and know what you are doing. It is very complete, but not easy to read.  :box:

I guess their are much better books. Wanted to point this out for a long time. Keep in mind I like the book

Understanding C is more than only the language. You also need to understand the architecture of the platform you like to target. Most limitations will come from this.

My two cents.  ;)


 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: c language sample codes and Book
« Reply #16 on: November 11, 2014, 08:38:06 pm »
I think you need a few types of books here:

1) K&R: to know the basics of C. It is a book to start with;
2) coding manuals / style books: most large firms have them.
3) coding "tricks" / traps: not a systematic way to learn C but a good way to avoid tricky mistakes. Read it only when you consider yourself to be 'fairly' good in C.

I wouldn't buy any "C on mcu" book: C is C. With minor exceptions, what you learned coding on a PC goes to coding in an enbedded environment.
================================
https://dannyelectronics.wordpress.com/
 

Offline con-f-use

  • Supporter
  • ****
  • Posts: 807
  • Country: at
Re: c language sample codes and Book
« Reply #17 on: November 11, 2014, 09:22:49 pm »
Sorry danny but that's just horrible advice.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6459
  • Country: nl
Re: c language sample codes and Book
« Reply #18 on: November 12, 2014, 07:51:41 am »
"The C Programming Language" has become a little old these days. Having taught C classes at two universities, I'd recommend K. N. King's book "C Programming: A Modern Approach".
I ordered this book after your post, I find it a bit too expensive (€75) but it is well written and I can now second it to recommend it to starters for getting the hang of C instead of K&R which might be to steep.
Also the explicit mentioning what parts are C (K&R-C), C89 and C99 are splendid since still not everyone uses a C99 compiler these days.
Good recommendation.
 

Offline ehughes

  • Frequent Contributor
  • **
  • Posts: 409
  • Country: us
Re: c language sample codes and Book
« Reply #19 on: November 12, 2014, 04:44:19 pm »
Some Starter Videos, projects if you are interested :

Bare metal bring up with the FRDM-KL25Z ($13 board):

https://community.freescale.com/docs/DOC-93960
https://community.freescale.com/docs/DOC-95170

They are not all encompassing but some of the MCU intro videos may help.   THere are examples for getting started doing basic board bring up


Some projects that use FRDM but are more focused on DSP.   Intended for just out of college students who have never coded any DSP, etc who need something a little more advanced than an LED blinker to get started.

https://community.freescale.com/docs/DOC-99621

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf