Coding AVRs with C?

Hi - I've done a small bit of coding on AVRs with AVR assembler. I've done enough that I can get a circuit to flash, a group of leds to count up, or something else simple like that. But I'd really like to learn C for the AVR. Does anybody have a suggestion for a good place to start? I have never coded in C, so I need to start from the absolute basics. Thanks so much!

-Michael Noone

Reply to
Michael Noone
Loading thread data ...

Are you already familiar with C? If not, get a good reference like Kernighan and Ritchie or Harbison and Steele. If you are, look at more advanced books like van der Linden's "Expert C Programming" and Heathfield et. al "C Unleashed" (which, unlike some other "Unleashed" books, is quite good).

Of course you'll need tools. You don't say what platform you'll be using, but avr-gcc is very good, and is probably hosted on your system. If you're on Windoze, WinAVR is a complete solution: avr-gcc, gdb, insight, chip programmer, editor/ide.

CodeVisionAVR makes programming AVRs in C almost trivial. Available in the U.S. from Programming resources

formatting link
There's also a book, Embedded C Programming and the Atmel AVR by Barnett et. al. that makes use of this tool. I've heard it's pretty good, but I've never looked at it myself. CVAVR is $150 for the standard edition, $90 for the "Light" edition (does not support ATmega parts), a free evaluation download (http://www.hpinfotech.ro/cvavre.zip), well supported, and easy to use. The book is about $68 from prllc, which is few dollars cheaper than Amazon.

More expensive options are available, e.g., from IAR. Also look at

formatting link
if you can stand the slow, ugly web interface.

HTH,

-=Dave

--
Change is inevitable, progress is not.
Reply to
Dave Hansen

snipped-for-privacy@hotmail.com (Dave Hansen) wrote in news: snipped-for-privacy@News.individual.net:

Nope - I don't know C at all. I was hoping to learn C through AVR programming, instead of first learning C on a computer and then moving to AVRs. I'm on a Windows XP system, but if needs be I can install a linux distro. WinAVR looks quite nice though. Oh, if it matters at all I use an Atmel AVRISP in combination with AVR Studio on my xp system. Currently my AVR of choice is the AT90S8515, though I've been eyeing the ATMEGA32... It looks mighty sexy... Thanks,

Michael

Reply to
Michael Noone
[...]

If you're comfortable in assembler, or with using pointers in any other language, I'd still suggest getting K&R. It's an easy read and doesn't talk down to you. Most of C isn't platform specific, and most of the book will apply to the AVR as much as anything else.

The Barnett et. al. book might be a quicker way in, since it's specific to the AVR. I've heard good things about it, but I haven't looked at it myself. And CVAVR makes it really (really) easy.

I'm more familiar with Windoze tools anyway. WinAVR, CVAVR, and IAR are all Windoze development host systems. As is AVR Studio.

I think the AT90S8515 is (or is about to be) obsolete -- I know the AT90S8535 has been replaced by the ATmega8535.

It's a nice part, but... sexy? You need to get out more often. ;-)

I've been using the ATmega16 for most things lately. Basically a mega32 with less memory. You can get an awful lot done in 16k on an AVR, even when writing in C...

Regards,

-=Dave

--
Change is inevitable, progress is not.
Reply to
Dave Hansen

Start out on

formatting link
by this

formatting link

Then go to the avr beginners site referenced there , then have a look at the free GCC C compiler called WinAvr (referenced in above link)

Carsten

Reply to
Carsten

It is far more easy to learn C in a PC environment. Go and see if you can buy or download a cheap or free Turbo C version 3 or so. Then you can write in C, compile, run and debug on a friendly platform.

If you want to start learing C on an embedded processor, you effectively have to learn two things at once: learn C and learn to start the code running on an embedded processor.

The AT90S8515 is obsolete for some time already.

Meindert

Reply to
Meindert Sprang

For the unwary, I'd recommend a Pascal

formatting link
or a basic (.. google ) And if a C, then perhaps
formatting link

Rene

--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
Reply to
Rene Tschaggelar

write

I think if He wants to program C for the AVR in the end, then it may save some time learning the AVR specific things, and run with the AVR Simulator.

But there is the ATmega8515 replacement.which should work as well.

--
Best Regards
Ulf at atmel dot com
These comments are intended to be my own opinion and they
may, or may not be shared by my employer, Atmel Sweden.
Reply to
Ulf Samuelsson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.