AVR Tutorial?

So I built a nice little programmer, and now I want to learn to program my AVR microcontrollers. WHERE DO I FIND A TUTORIAL?! I've been looking for hours, and all I can find is information on building a programmer for AVR microcontrollers. I already did that! I can't find a single tutorial on how the programming language for AVRs work. Does anybody know where I can find a tutorial on the programming language for AVRs, or the AVR assembly lnaguage? This is the only thing that there seems to be nothing about on the internet.

sort by: active | newest | oldest
1-10 of 13Next »
1o_o72 years ago
Get Atmels hardware reference. Embedded programming is NOT abstracted from the hardware like PC programming. 'C', Pascal, Arduino C++ or whatever are intimately involved with the AVR metalwork. Without the hardware references you just won't get the reasons for a lot of the code work.
gmoon6 years ago
You must be looking in the wrong place, there are tons of AVR tutorials on the web. Either type in your chip name and tutorial, i.e., "atmega8 tutorial", or "avr gcc tutorial".

This simple tutorial
got me started a few years ago...

There isn't an official "programming language for AVRs," but most people start with the free "C" compiler, AVR GCC--either in Linux or using AVR Studio and the WINAVR package (AVR GCC for windows).

If you've never worked with "C" before, there will be a learning curve...
gimmelotsarobots (author)  gmoon6 years ago
There is no explanation of the code on that site.
What does this bit mean?
DDRC|= _BV(PC5);
It says in the code comments that is sets PC5 as an output. But what does DDRC|= do? Why is there an underscore, and what is the BV before (PC5)?

PORTC&= ~_BV(PC5);
delay_ms(500);
/* set output to 5V, LED off */
PORTC|= _BV(PC5);
delay_ms(500);

This is from that page. what does the tilde on the first line mean? and why does one line use the "|" character and the other use the "&" character? The reason I can't find tutorials is because nobody is explaining the example code. What If I want to do something other than blink an LED? I want to understand it so I can create my own code.
I think you need to brush up on the more esoteric programming points of C and have a feel for what the program is for. In any programming language there may be weird functions or syntax that are not common and may have been used in the chunk of code you are trying to decipher. Maybe that's why more complex bits of code are just copied and used but never understood.

I do not know C, C++, or variants...maybe a little, but you can try to google the unknown syntax. Since you are dealing with LED switching from an IC, you should think of light switches which can be on/off - bit values, signals to tell it when to turn on thus Hi/Lo signals, address or ports, positions to receive the message. So clues are there to figure out what the state or status of a bit value of the pin on the IC, hopefully you have names that remind you of what variable you are dealing with and know what you can name them (underscore character too) and then figure out if there are ways of doing boolean or bit wise functions. Thus some new syntax to do that knowing your variables to compare are just 1 and 0. Compact and efficient code in the least lines possible is a programming art and skill. I hope that helps a little. Good luck.

gimmelotsarobots (author)  caitlinsdad6 years ago
The problems I'm having are these little bits of C specific of AVRs. I need to know what they mean in order to make my own programs. I don't intend to do simple timing and blinking on every project. I need to be able to do more complex things like run a color graphical LCD. If I don't even know what the little bits of blinking an LED mean, how am I to do that? What I need is a teacher specifically on this subject. The C tutorials at cprogramming.com are great, but they don't cover microcontrollers. What I am looking for is something similar to cprogramming.com, but about AVRs. I just don't understand whey these AVR tutorials aren't explaining the code. What is so hard about that? And how did they learn?
Sheeze, the "Rich Editor" dropped my lengthy comment twice (will they ever wise-up and dump the buggy "custom" forum here?)

Sorry, consequently I'm in a foul mood. So for now I'll just leave you with this tutorial link on bit wise operator use in AVRs.
Hmmm, it seems you seek the ways of the Jedi AVRprogrammer. I'm thinking that you already have the hardware setup. Have you actually flashed your first bit of code to make a single led light up? Then you know you can actually get a program onto the chip.

Next, can you make your single LED blink?
Can you make it turn on and off based on a table of values, can you program or work with arrays?
Can you vary the time the LED blinks on and stays off.
What values are good to make it flash or do a smooth fade?

Programming is taking a simple program and adding on to it. Rename the variables so you can understand. Nowadays everyone expects to be able to program something by just dragging a block of code into a box and thinks it will work. You need to be able to think and flowchart logically what you want to do.
You build up experience from simple programs and using more functions. Understand how the syntax works. Figure out how looping works.
Running a full color graphical LCD can be broken down in simpler steps of addressing a thousand pixels or more based on what you know about blinking a single LED. Coding can be frustrating and using weird syntax can be confusing but once you start out with the basics, you get experience fast.
gimmelotsarobots (author)  caitlinsdad6 years ago
I understand that, the trouble is finding what syntax is used for AVRs. For instance, in C, scanf reads a value from user input when set up like

scanf( %d, &variable_name);

If I didn't know how to use scanf, or that it existed, I wouldn't be able to use it.
So mostly what I need is sort of a list of commands for AVRs being programmed in C, and their syntax. But I still need some tutorials to teach me when to use them.
Like this
or this
etc.

Practice your google-fu.
1-10 of 13Next »