As far as microcontrollers are concerned, there are thousands of options for you to pick from. They range from the 8 bit AVRs all the way to 32 bit STM micrcontrollers. The 32 bit micrcontrollers are becoming far more popular in modern products, but 8 bit micrcontrollers remain extremely popular in hobbyist settings, especially ATMEL’s line of AVR microcontrollers. This can especially be attributed to the popularity of the arduino, which uses a wide range of AVR microcontrollers. Especially the arduino UNO, which uses the now famous atmega328p. However, microchip, which now owns ATMEL, has released a new line of AVR microcontrollers, which they call the megaAVR 0 series. This new series has a lot of improvements over the older AVR chips, and in this video we will review the changes made in the new series, and determine whether you should start using them in your own projects, because although they both share the ‘atmega’ name, they aren’t exactly the same.
First, let’s look at the cost of the microcontroller itself, because that is the thing that will determine if the new series and its features are worth the cost. For this comparison, we will look at the atmega328p and the atmega4808 because they are both about the most powerful version of the other microcontrollers in their line. It is also worth keeping in mind that, they both have other micrcontrollers in their lines that are exactly the same, except that their avaliable ram and flash is lowered in exchange for a lower price. Anyways, at digikey the atmega328p costs $3.11 for one. On the other hand, the atmega4808 only costs $1.85, again at digikey, which makes it far more cost effective on a per chip basis. Another point to mention is that the newer atmega4808 actually has stock at the time of making this video, whereas the older atmega328p has a serious shortage, meaning that one of the only ways to get your hands on one of them is to literally just to buy a premade development board and desolder it. So, lets look at the features to see if the cost really tells us if the new AVRs are really better and more cost effective.
Let’s start with the basic specifications of performance on both of these microcontrollers, all of which can be found on the datasheet of each microcontroller respectively. The 328 has 32 kilo bytes of flash memory, whereas the 4808 has 48 kilo bytes of flash. The 328 has 1 kilo byte of eeprom, and the 4808 has a smaller 256 bytes of eeprom. The 328 has 2 kilo bytes of SRAM, and the 4808 has 6 kilo bytes of SRAM. Both of them have a maxmimum clock speed of 20 MHz, however, it is worth noting that the 328 requires an external clock source to reach those speeds, whereas the 4808 can be configured to run with an internal 20 MHz clock, reducing the total part count required when higher clock speeds are needed. They both run the AVR CPU internally so they are just about the same when it comes to CPU architecture. So far, it seems that the 4808 is winning when it comes to CPU resources, but that is only a part of the considerations that need to be made when choosing a microcontroller.
Let’s look at the peripherals, because that really is the most important part of a microcontroller in most cases. Starting with the general purpose I/O lines, both have 23 I/O pins, unless you buy the 32 pin atmega4808, that one has 27 I/O pins. The 328 has one 16 bit and two 8 bit hardware timers. The 4808 does much better in this regard, because not only does it have four 16 bit hardware timers but also a 16 bit RTC that can be run from an external crystal. So if your project has a lot of timing needs, you probably already see the benefit of the new AVR series. Continuing, the 328 only has one USART, which oftentimes is already taken up by the arduino bootloader, if you are using it on an arduino that is, and the 4808 has three of them. They both have an ADC, but the 328 has only 6 or 8 channels depending on the package, and the 4808 has 8 or 12 channels, again depending on the package. Many of the other features are the same, such as 1 SPI, 1 TWI, and one analog comparator. However, one of the things that really sets the 4808 apart from the 328 is the CCL, or configurable custom logic, and the event system. The CCL allows us to create our own logic system between internal and external peripherals without any CPU use or extra logic hardware. The event system allows us to create links between internal peripherals and cause actions without alerting the CPU. These two features allow for cleaner code execution because the CPU will not have to execute as much code when the hardware automatically handles connections between peripherals. So, the improved peripherals in the 4808 is definetly a big selling point and will be very convenient when it comes to designing a project with a microcontroller.
However, there is still another important aspect of use that we have to cover: and that is how we will be programming these microcontrollers. On the older AVRs, we typically used ISP to program, unless you were using an arduino or similar, and in that case it would have been via a bootloader reading from the UART. When using ISP programming, there are several methods to do so. I used to use this AVRISP MK II for a while, until I upgraded to this ATMEL ICE, which I do recommend by the way. If you feel that these programmers are too expensive, you can also opt for using another microcontroller as a programmer, because it simply is just the SPI protocol. Another method for the older AVRs is the pin intensive parallel programming method. While I do not typically use this method, it is useful for saving the microcontroller if you programmed a fuse incorrectly. On the other hand, the new megaAVRs use the UART based UPDI, which stands for unified program and debug interface. This is the reason why I bought the ATMEL ICE, because it supports UPDI while the AVRISP MK II does not. UPDI is the best so far in terms of pin use, because it only requires one pin, three if you count VCC and ground. There is another more complicated method involving a USB to UART ic such as the CH340, because UPDI is Uart based, but I will cover that in a future video. So, if you plan to buy either of these microcontrollers, just keep in mind which programmers you have or will have to buy, if you aren’t sure, just remember that the ATMEL ICE can program not only both of these microcontrollers, but also atmel’s SAM series of MCUs.
Another thing to note is the packages that these microcontrollers come in. The older AVRs, such as the mega328 all have both SMD and DIP packages avaliable. However, the new AVRs, or the mega4808, are only avaliable in SMD packages, meaning that if you plan to use them on a breadboard, you will have to make an adapter. However, if you are using a development board the package shouldn’t matter too much.
Now let’s figure out the differences between both when it comes to writing code. They are both similar, just with additional registers in the 4808. However, the 328 has a massive advantage in that it has a couple of communities behind it with a lot of code already written. Places like AVR freaks already discuss the workings of AVR microcontrollers, but the arduino community has so many libraries and example schetches written, that even if you aren’t using an arduino, but rather using the microcontroller standalone, you have a lot of places to reference if you get stuck. The 4808 will get some support with time, especially considering that arduino released their Arduino Nano Every which includes an atmega 4809, which is simply a better 4808. However, if you are still learning how to use these microcontrollers, it is definetly worth thinking about whether you will need some support writing code for your project.
Now, to demonstrate the differences between the two microcontrollers, I will be writing a simple program that will dim and brighten an LED, using the hardware timer. I will be using my custom boards for each test, and the schematic and code for each can be found in the description.
So after reviewing both of these microcontrollers, its clear to say that the new megaAVR series is actually more cost effective and has better features overall. If you are able to write code for the megaAVR series, I would say that it is clearly the better choice. However, if you are still new to electronics and microcontrollers in general, then you might want to experiment with the old AVR series because of its immense support and existing codebase.