The AVR microcontroller is a new type of microcontroller developed by Atmel Corporation. Compared with the 51 microcontroller and PIC microcontroller, it has a series of advantages:
AVR runs the fastest under the same system clock.
The chip has a large capacity for its internal Flash, EEPROM, and SRAM.
All models of Flash and EEPROM can be repeatedly programmed and all support in-system programming (ISP).
It features an internal RC oscillator with multiple frequencies, automatic power-on reset, watchdog timer, and startup delay, and can operate with zero external circuitry.
Each I/O port can output high and low levels in a push-switch driver manner, with strong driving capability;
It has abundant internal resources, generally integrating AD and DA analog-to-digital converters; PWM; SPI, USART, TWI, I2C communication ports; and a rich set of interrupt sources.
Currently, the languages that support AVR microcontroller compilers mainly include assembly language, C language, and BASIC language. Among them, C compilers mainly include CodeVisionAVR, AVRGCC, IAR, and ICCAVR. Due to its inherent advantages such as powerful functions, flexible use, small code size, and fast execution speed, C language compilers have an irreplaceable position in professional programming.
The AVR microcontroller is a high-speed 8-bit microcontroller with an enhanced built-in Flash RISC (Reduced Instruction Set CPU) architecture, developed by Atmel in 1997. AVR microcontrollers can be widely used in various fields such as computer peripherals, industrial real-time control, instrumentation, communication equipment, and home appliances.
Key features of AVR
High reliability, powerful functions, high speed, low power consumption, and low price have always been important indicators for measuring the performance of microcontrollers, and are also necessary conditions for microcontrollers to occupy the market and survive.
Early microcontrollers, primarily due to limitations in manufacturing processes and design, high power consumption, and poor interference immunity, employed a conservative approach: using a high clock division factor, resulting in long instruction cycles and slow execution speeds. While later CMOS microcontrollers adopted measures such as increasing clock frequencies and reducing division factors, this fundamental issue was not completely resolved (for 51 microcontrollers and 51-compatible microcontrollers). Although some Reduced Instruction Set Computing (RISC) microcontrollers emerged during this period, they still adhered to the practice of clock division.
The introduction of AVR microcontrollers completely broke this old design pattern, abolishing the machine cycle and abandoning the pursuit of instruction completeness in Complex Instruction Set Computers (CISC). Instead, it adopted a Reduced Instruction Set Computing (RISC) system, using words as the unit of instruction length. It arranged rich operands and opcodes within a single word (as is the case for the majority of single-cycle instructions in the instruction set), resulting in short instruction fetch cycles and the ability to prefetch instructions, enabling pipelined operations and thus high-speed instruction execution. Of course, this leap in speed is backed by high reliability.
The AVR microcontroller hardware architecture adopts a compromise strategy between 8-bit and 16-bit systems, employing a local register stack (32 register files) and a single high-speed input/output scheme (i.e., input capture register, output compare/match register, and corresponding control logic). This improves instruction execution speed (1 Mips/MHz), overcomes bottlenecks, and enhances functionality; simultaneously, it reduces the overhead of peripheral management, simplifies the hardware structure, and lowers costs. Therefore, the AVR microcontroller achieves an optimized balance in terms of software/hardware overhead, speed, performance, and cost, making it a high-performance, cost-effective microcontroller.
AVR microcontrollers feature embedded high-quality Flash program memory, which is easy to erase and write, supports ISP and IAP, and facilitates product debugging, development, production, and updates. The embedded long-life EEPROM can store critical data for extended periods, preventing data loss in the event of power failure. The large on-chip RAM not only meets general usage needs but also effectively supports the development of system programs using high-level languages and can be expanded with external RAM like the MCS-51 microcontroller.
The AVR microcontroller features all I/O lines with configurable pull-up resistors, can be individually set as input/output, can be set to (initial) high impedance input, and has strong driving capability (eliminating the need for power driving devices), making its I/O port resources flexible, powerful, and fully utilized.
The AVR microcontroller features multiple independent clock dividers for use with URAT, I2C, and SPI. Among them, the 10-bit prescaler, used with 8/16-bit timers, allows for software-configurable division ratios to provide various timing levels. AVR's unique design method—using a timer/counter (single) to generate a triangular wave and then combining it with an output compare-match register to create a square wave with variable duty cycle, frequency, and phase (i.e., pulse width modulation output PWM)—is particularly innovative.
The enhanced high-speed synchronous/asynchronous serial port features hardware-generated checksums, hardware detection and error checking, two-level receive buffering, automatic baud rate adjustment (during reception), and data frame masking, improving communication reliability, facilitating program writing, and making it easier to form distributed networks and implement complex multi-machine communication systems. Its serial port functionality far exceeds that of the MCS-51/96 microcontroller. In addition, the AVR microcontroller is high-speed with short interrupt service time, thus enabling high baud rate communication.
The system utilizes high-speed, byte-oriented hardware serial interfaces TWI and SPI. TWI is compatible with the I2C interface and features hardware transmission and recognition of ACK signals, address recognition, and bus arbitration, enabling multi-machine communication with all four master/slave transmit/receive combinations. SPI supports multi-machine communication with all four master/slave combinations.
The AVR microcontroller features an automatic power-on reset circuit, an independent watchdog circuit, a low-voltage detection circuit (BOD), multiple reset sources (automatic power-on/off reset, external reset, watchdog reset, and BOD reset), and a configurable startup delay before program execution, enhancing the reliability of the embedded system.
AVR microcontrollers have multiple power-saving sleep modes and can operate at a wide voltage range ( 5-2.7V ). They also have strong anti-interference capabilities, which can reduce the workload of software anti-interference design and the amount of hardware used in general 8-bit microcontrollers.
AVR microcontroller technology embodies the integration of multiple components (including FLASH program memory, watchdog timer, EEPROM, synchronous/asynchronous serial port, TWI, SPI, A/D analog-to-digital converter, timer/counter, etc.) and multiple functions (reset system for enhanced reliability, sleep mode for reduced power consumption and anti-interference, a variety of interrupt systems, timer/counters with diverse functions such as input capture and comparison matching output, I/O ports with replacement functions, etc.) into one microcontroller, fully demonstrating the development direction of microcontroller technology from "self-contained" to "System-on-a-Chip (SoC)".
In conclusion, AVR microcontrollers combine the strengths of many technologies and possess unique features, making them truly outstanding among 8-bit microcontrollers.
Selection of AVR series microcontrollers
AVR microcontrollers offer a complete range of products to meet the requirements of various applications.
AVR microcontrollers come in three tiers:
Low-end Tiny series AVR microcontrollers: mainly Tiny11/12/13/15/26/28, etc.
Mid-range AT90S series AVR microcontrollers: mainly including AT90S1200/2313/8515/8535, etc. (currently being phased out or transitioning to Mega series).
High-end ATmega series AVR microcontrollers: mainly ATmega8/16/32/64/128 (with storage capacity of 8/16/32/64/128KB) and ATmega8515/8535, etc.
AVR devices have pinouts ranging from 8 to 64, and various packages are also available.