Into to programming atmel chips

Last post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does any one know where I can find a good tutorial or two on programming Atmel chips in either c or c++? I'm not new to programming, I know enough c++ to get me by but when it comes to programming chips it beats me.
Any help would be great, thanks.
Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some of those helped me a bit but I'm looking for a straight up AVR c tutorial as I know how to program but I don't understand all the terms and stuff for programming an Atmel or other chip in c/c++. There's a link on there for AVR c tutorial but it's no longer around. Thanks though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you bothered to scroll down the page I provided and check every related link?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When you say 'programming', do you mean transferring the hex file to the avr to be burned in flash? Or do you mean typiing c source code into an ascii file to be compiled? Compiling can be done using avrstudio, free download from atmel.com. Burning can be done using avrstudio and an avrisp mkii $35 from atmel store.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

no I haven't clicked on every link as not every link is going to help me. I checked everything under beginners sites and learning AVR assembly as well as learning c and tutorials and good manual entries. Like said some of it explained stuff to me and I got a better look at what I was trying to figure out.
I somewhat understand addressing on the chips now (still have to read up more on it) and other stuff like that.
I'm still confused on all of the different terms with programming it, like DDRD and PORTB and all that jazz for doing simple I/O stuff, I'll get into more advanced later.
I don't get what those terms mean or exactly how to use them. I get that you say, for example DDRB = 0xFF to set pins as outputs, but exactly what pins and what writing that does I don't know.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By programming I mean writing c code, sorry. I know how to use AS4, make hex files and transfer code to chips, I just don't know how to write the code for the chips.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try reading the "C in 16 pages" chapter in the imagecraft help file in the demo version of the compiler.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He did even better - has read the "Newbie" tutorial in 14 minutes since I posted the link :lol:

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to read the datasheet for the chip you are using. It will tell you what "DDRD and PORTB and all that jazz" is.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

7Dswinger wrote:
I just don't know how to write the code for the chips.
You don't need to - any code already exists on the Internet. Just google for it and enjoy :lol:

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

True but where's the fun in that when you want to write code to have a chip do something for you?

I'll check the "c in 16 pages" articlel, Thanks
Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're working with the bare metal, so reading the datasheet is where to begin. If this is all a bit too steep, get your feet wet with the arduino, then step up.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I'm still confused on all of the different terms with programming it, like DDRD and PORTB and all that jazz for doing simple I/O stuff
But DDRD and PORTB have nothing directly to do with C, they are registers available on an AVR. In C they are simply defined as 8 bit variables that you access just like any other variable. To know what accessing them does, you need to read the datasheet of the chip.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
But DDRD and PORTB have nothing directly to do with C, they are registers available on an AVR. In C they are simply defined as 8 bit variables that you access just like any other variable. To know what accessing them does, you need to read the datasheet of the chip.

No I understand that, it's just like any other piece of code in c or c++. I'm just sure what all of them are and how to use them as with all of the 0xFF and 0x18 to address them, I don't understand that at all. I'll check the data sheet and see what I can find

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok so after looking at the data sheet under the peripheral address map on an xmega32A4 in the code when you write, for example 0x0600, you'd be calling up portA?
I'm still confused on what DDRD and stuff is as when I looked over the data sheets they were never mentioned.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should start with an ATmega AVR then progress to the Much More Complicated Xmega AVR

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ya I probably should but I've got an Xmega on my hands right now for a little while so I thought I might as well.
So you'd recommend something like an ATtiny85-20PU as a good place to start?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd get an arduino uno at radio shack for $30 bux. Uses an ATmega328. Read the datasheet, see if it looks simple.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Ok so after looking at the data sheet under the peripheral address map on an xmega32A4 in the code when you write, for example 0x0600, you'd be calling up portA?

Yes and no. That might be the address for PORTA, but any decent compiler will supply a set of include files for different AVR models so that you can simply use the symbolic name. E.g.

PORTA = 0x08;

I.e. set bit number 3 (with bit being numbered 7..0). Mind you, you will soon be adviced to not use that "magical number" in hex notation but rather do

PORTA = 1<<3;

but that is nothing specific to AVRs but again standard C.

My advice would be to arm yourself with the data sheet, and then start looking at some of the tutorials here at AVRfreaks. Mr Dean Camera, known here as 'abcminiuser', has written several tutorials that are very good. Now, even if you do not plan to use timers to start with, you can still inspect them and use them as an example of well written code. Then cross reference the daat sheet to see what he is doing. If you do not reveal every detail at this stage then that is no trouble, since you are using the tutorials as a vehicle for getting a feel for the terrain ahead.

And if that shifting operation above seems exotic to you, then the very first tutorial to read is posted by Dean but actually written by Eric Weddington ('EW'), and is entitled "Bit manipulation" or some such. There are good clues and examples of simple digital port I/O in that tutorial.

Another resident AVRfreaks, Joe Perdue, known here as 'smileymicros', have a book on beginning AVR stuff with a smaall card called AVR Butterfly. IIRC you can download the first few chapters for free from his site: www.smileymicros.com . He is a good tech-teaching writer IMO, and even though the book is specific for the Butterfly (and the AVR on it, ATmega169) AVRs are similar enough so that you might use this as an intro to programming AVRs in C.

Lastly, we have a project section here at AVRfreaks. There are thousands of worked projects. They vary greatly in quality, technical complexity, and "narrowness-of-application". While daunting perhaps, you might browse through a few pages of the projects list and see if there is something that seems easy enough to start with and interests you.

HTH!

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok that makes sense.
So with the Arduino it uses the same architecture as an AVR due to the fact that there's an AVR chip on there?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I always thought Architecture had to do with buildings. The Arduino Uno does in fact have an Atmel ATmega328 on it. It comes with arduino software already in it that makes it Real Easy to load an Arduino program. But dumb old guys like me just write a regular old c program and upload it to the arduino using the free avrdude program.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bobgardner wrote:
It comes with arduino software already in it that makes it Real Easy to load an Arduino program.

Bob, the Arduino bootloader will also let you upload your C programs with avrdude too.

 -c arduino -P com4 -p m328 -b 57600 -D -U flash:w:yourprogram.hex:i: 

You do have to change the COM port and the part to that of the Arduino you are using.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I always thought Architecture had to do with buildings.

Never too late to be enlightened, Bob: http://en.wikipedia.org/wiki/Computer_architecture . :D

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington]