Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
7Dswinger
PostPosted: May 06, 2012 - 06:44 PM
Newbie


Joined: May 02, 2012
Posts: 16


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
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: May 06, 2012 - 06:47 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

Here you are.

_________________
Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
 
 View user's profile Send private message  
Reply with quote Back to top
7Dswinger
PostPosted: May 06, 2012 - 07:01 PM
Newbie


Joined: May 02, 2012
Posts: 16


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.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: May 06, 2012 - 07:04 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

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.
 
 View user's profile Send private message  
Reply with quote Back to top
bobgardner
PostPosted: May 06, 2012 - 07:14 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 23986
Location: Orlando Florida

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
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
7Dswinger
PostPosted: May 06, 2012 - 07:20 PM
Newbie


Joined: May 02, 2012
Posts: 16


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.
 
 View user's profile Send private message  
Reply with quote Back to top
7Dswinger
PostPosted: May 06, 2012 - 07:21 PM
Newbie


Joined: May 02, 2012
Posts: 16


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.
 
 View user's profile Send private message  
Reply with quote Back to top
bobgardner
PostPosted: May 06, 2012 - 07:26 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 23986
Location: Orlando Florida

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

_________________
Imagecraft compiler user
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
MBedder
PostPosted: May 06, 2012 - 08:19 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

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

_________________
Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: May 06, 2012 - 09:28 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3147
Location: Redmond, WA USA

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.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: May 06, 2012 - 09:31 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

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 Laughing
 
 View user's profile Send private message  
Reply with quote Back to top
7Dswinger
PostPosted: May 07, 2012 - 02:52 PM
Newbie


Joined: May 02, 2012
Posts: 16


[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
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: May 07, 2012 - 03:11 PM
10k+ Postman


Joined: Dec 30, 2004
Posts: 11690
Location: Melbourne,Australia

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.
 
 View user's profile Send private message  
Reply with quote Back to top
Koshchi
PostPosted: May 07, 2012 - 03:30 PM
10k+ Postman


Joined: Nov 17, 2004
Posts: 15021
Location: Vancouver, BC

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.
 
 View user's profile Send private message  
Reply with quote Back to top
7Dswinger
PostPosted: May 07, 2012 - 04:59 PM
Newbie


Joined: May 02, 2012
Posts: 16


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
 
 View user's profile Send private message  
Reply with quote Back to top
7Dswinger
PostPosted: May 07, 2012 - 05:52 PM
Newbie


Joined: May 02, 2012
Posts: 16


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.
 
 View user's profile Send private message  
Reply with quote Back to top
bobgardner
PostPosted: May 07, 2012 - 06:10 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 23986
Location: Orlando Florida

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

_________________
Imagecraft compiler user
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
7Dswinger
PostPosted: May 07, 2012 - 06:19 PM
Newbie


Joined: May 02, 2012
Posts: 16


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?
 
 View user's profile Send private message  
Reply with quote Back to top
bobgardner
PostPosted: May 07, 2012 - 06:24 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 23986
Location: Orlando Florida

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
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
JohanEkdahl
PostPosted: May 07, 2012 - 06:25 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 22061
Location: Lund, Sweden

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.

Code:
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

Code:
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!
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits