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.” Brilliant engineers don’t fight – they choose the one that will do the job with less effort, less cost, and probably the most familiar one.
Let’s stick with AVR for a while, as it is quite a favorite type among today’s hobbyists. Who doesn’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 other 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 since it’s been in my head, so I decided to give it a try – write a tutorial that would show the basics of interfacing and programming AVR and understand 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 isn’t good. Most microcontrollers have enough resources to keep up with non-effective programs. But programs tend to grow more prominent this way, and more visible problems become. Learning to do it right at the beginning is better than trying to change things later. This saves time.
In this AVR tutorial set, I will gradually display things from fundamental 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 humans. In another hand program, it can be straightforward and convenient for humans but not as suitable for machines.
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 is missing. Nobody is perfect, so that many things may be missing. I am still learning a lot. I hope you and I will enjoy the process and results.