AVR family is one of the leading 8-bit microcontrollers in its family. There are many reasons why many hobbyists chose this one among others. I don’t say that other families like PIC are worse – no way – can you find even better solutions if needed. Let’s not get into a big fight “what’s the best.” Smart engineers don’t fight – they choose the one that will do the job with less effort, less cost and probably the one that are most familiar.
Let’s stick with AVR for a while as it is quite a favorite type among today’s hobbyists. Who don’t know Arduino? It is also based on AVR MCUs. So, interest in AVR is significant, demand is big, but one thing is missing – knowledge on how to program these babies effectively. You can find tons of various libraries and tutorials on how to do simple tasks like LED blinking, USART, I2C SPI communications, and another interfacing. This is great, but when your project grows into something more significant you are stuck because simple big while() loop in the main routine can’t do business anymore.
Long time it’s been in my head, so I decided to give it a try – write a tutorial that would show the very basics of interfacing and programming AVR along with understanding what is going on when it is running. I bet very few people are programming in ASM language. And even fewer are familiar with it. Especially starters are stuck with C or other higher level languages with no idea what happens in hardware. I don’t say this is bad. Most microcontrollers have enough resources to keep up with non-effective programs. But programs tend to grow more prominent this way more visible problems become. It is better to learn to do it right at the beginning than try to change things later. This saves time.
In this AVR tutorial set, I am going to display things gradually from very basic towards more sophisticated and efficient ways of solving problems. You will have to choose what’s best for you. The word efficient is very “slippery” meaning that code may be very efficient for the machine but not readable for human in another hand program it can be straightforward and convenient for human but not as good for machine.
And yes, the tutorial is going to be based on C language (AVR GCC). For more in-depth analysis may be ASM introduced to show what’s going on underwater. All code examples will be published from real working programs. So you’ll be able to download and try them by yourself. Don’t hesitate to comment, correct or add if something will be missing. Nobody is perfect so many things may be missing. I am still learning a lot. I hope you and I will enjoy the process and results.