This is a complete AVR Tutorial, including avr programming in a very basic & organized way, We will go through by following items.
- What is an AVR?
- Using Mac and Windows
- How AVR programming works
- Choosing a programmer, to burn the code.
- Using AVRDUDE
This set of notes does have some prerequisites. It requires two important sets of knowledge:
- You must know how to use the command line for your OS, either Terminal (Mac, Unix) or cmd/DOS (Windows).
Here is a tutorial for Macs
Here is one for Linux (Ubuntu)
Here is one for Windows
- You must know how to program, preferrably in C.
The fact is, most microcontrollers are programmed in C, its a lightweight programming language that is well suited to the restrictive environment. You can also do many of these examples in BASIC but I doubt I’ll have time to put up those versions
Here is a tutorial
I learned C about 12 years ago from a book that came with a CD and had lots of examples, I think it was “Learn C in 21 days” or some nonsense. It doesn’t matter how you do it, but this tutorial assumes that you know what a for loop is and how bit-wise arithmetic work, etc.
You also need to be able to convert hex, binary and decimal (using a calculator).
Microcontrollers are tougher to program because there is limited debugging capability.
What is a microcontroller?
The best way to explain what a microcontroller is, is to start with your computer. Your desktop computer (or laptop) is comprised of multiple parts, a CPU (such as a Pentium or Celeron), some RAM, a hard disk, a keyboard and mouse and a monitor screen. Programs are stored on the hard disk and run on the CPU, with temporary data stored in RAM. You can run multiple programs at a time by having one ‘master program’ called an operating system (such as Linux, Windows or Mac OS X) and that master program keeps track of things for you.
The AVR chip has components, too. It has a CPU, some flash storage, some RAM and some EEPROM, all in one little chip!. The CPU is just like the one in a computer, but its much simpler and not nearly as fast (what do you expect for $2.50?) The flash storage is just like the flash storage in your mp3 player or digital camera card, except its used to store programs. Its kinda like the hard disk of the microcontroller, except you can only read from it. The RAM is just like computer RAM. The EEPROM is kinda like flash except you cant run a program from it, but its used as long term storage. The EEPROM doesnt get erased when the chip loses power.
So, to recap: The AVR chip runs whatever program is stored in the flash, uses the RAM for temporary storage and the EEPROM for longer term storage.
Most computers have a 32-bit CPU running at 1GHz, with 1GB of RAM and 100 GB of storage. The kinds of microcontrollers discussed here run at 10MHz, have 1KB of RAM and 10KB of storage. (On the order of) However, their small size, lower power consumption and low cost make them an excellent choice for many projects!
For more details visit: AVR Programming & Basic AVR Tutorial