Microcontrolador AVR: tudo o que você precisa saber – (Parte 1/46)

AVR microcontroller: everything you need to know – (Part 1/46)

Microcontroller: Microcontroller can be termed as a single chip computer which includes various peripherals like RAM, EEPROM, timers etc. which are required to perform some predefined task.
Diagrama de blocos mostrando a arquitetura do microcontrolador AVR
Figure 1: Block diagram showing the AVR microcontroller architecture
Does this mean that microcontroller is another name for computer…? The answer is no!
Computer on one hand is designed to perform all general purpose tasks in a single machine like you can use a computer to run software to perform calculations or you can use a computer to store some multimedia file or to access the Internet through the browser, whereas microcontrollers are intended to perform only specific tasks, for example, automatically turning off the AC when the room temperature drops to a certain set limit and turning it on again when the temperature rises above the set limit.
There are several popular families of microcontrollers that are used in different applications according to their capability and feasibility to perform the desired task, the most common ones are 8051, AVR and PIC microcontrollers. In this article we will introduce you to the AVR family of microcontrollers.
AVR History
AVR was developed in the year 1996 by Atmel Corporation. The AVR architecture was developed by Alf-Egil Bogen and Vegard Wollan . AVR derives its name from its developers and stands for A I-Egil Bogen V Egard Wollan R Microcontroller ISC also known as A advanced V virtual R ISC. The AT90S8515 was the first microcontroller based on AVR Architecture , however, the first microcontroller to reach the commercial market was the AT90S1200 in 1997.
AVR microcontrollers are available in three categories:
1. TinyAVR – Less memory, small size, only suitable for simpler applications
two. MegaAVR – These are the most popular, with a good amount of memory (up to 256 KB), a greater number of built-in peripherals and suitable for moderate to complex applications.
3. XmegaAVR – Used commercially for complex applications that require large program memory and high speed.
The following table compares the AVR microcontroller series mentioned above:
Series name
Pins
Flash memory
Special feature
TinyAVR
6-32
0.5-8KB
Small in size
MegaAVR
28-100
4-256 KB
Extended peripherals
XmegaAVR
44-100
16-384 KB
DMA, event system included

Importance of AVR

What's special about the AVR?
They are fast: AVR microcontroller executes most instructions in a single execution cycle. AVRs are about 4 times faster than PICs, consume less power and can be operated in different power saving modes. Let's make a comparison between the three most used microcontroller families.
8051
PHOTOGRAPH
AVR
SPEED
Slow
Moderate
Fast
MEMORY
Small
Big
Big
ARCHITECTURE
CISC
RISC
RISC
ADC
Not present
Built-in
Built-in
Timers
Built-in
Built-in
Built-in
PWM channels
Not present
Built-in
Built-in
AVR is an 8-bit microcontroller belonging to the reduced instruction set computer ( RISC ) family. In RISC architecture, the computer's instruction set is not only fewer in number but also simpler and faster in operation. The other type of categorization is CISC (Complex Instruction Set Computers). Click to discover the differences between RISC and CISC. We will explore more about this when we learn about the architecture of AVR microcontrollers in the following section.
Let's see what this all means. What is 8 bits? This means that the microcontroller is capable of transmitting and receiving 8-bit data. The available input/output registers are 8 bits. AVR family controllers have a register-based architecture, which means that both the operands of an operation are stored in a register and the result of the operation is also stored in a register. The following figure shows a simple example performing the OR operation between two input registers and storing the value in the output register.
Diagrama de blocos mostrando um exemplo simples de execução de operação OR entre dois registros de entrada e armazenamento de valor no registro de saída
Figure 2: Block diagram showing a simple example of performing OR operation between two input registers and storing value in the output register

The CPU takes values ​​from two input registers INPUT-1 and INPUT-2, performs the logical operation and stores the value in the OUTPUT register. All this happens in 1 execution cycle.

In our AVR journey we will be working on the Atmega16 microcontroller, which is a 40-pin IC and belongs to the megaAVR category of AVR family. Some of the features of Atmega16 are:

· 16 KB of Flash memory
· 1 KB of SRAM
· 512 bytes of EEPROM
· Available in 40-pin DIP
· 8-channel, 10-bit ADC
· Two 8-bit timers/counters
· A 16-bit timer/counter
· 4 PWM channels
· System Programmer (ISP)
· USART Series
· SPI Interface
· Digital to analog comparator.

AVR architecture

AVR microcontrollers are based on advanced RISC architecture and consist of 32 x 8-bit general-purpose working registers. Within a single clock cycle, the AVR can receive inputs from two general-purpose registers and place them in the ALU to perform the requested operation, and transfer the result back to an arbitrary register. The ALU can perform arithmetic and logical operations
over the register inputs or between the register and a constant. Single-register operations, such as getting an add-on, can also be performed on the ALU. We can see that the AVR does not have any registration as an accumulator like the 8051 family of microcontrollers; operations can be performed between any of the registers and can be stored in any of them.
The AVR follows the Harvard Architecture format, in which the processor is equipped with separate memories and buses for Program and Data information. Here, while an instruction is being executed, the next instruction is prefetched from the program memory.
Diagrama de blocos da arquitetura de memória em AVR
Figure 3: Block diagram of the memory architecture in the AVR
Since AVR can perform single-cycle execution, it means AVR can execute 1 million instructions per second if the cycle frequency is 1MHz. The higher the controller's operating frequency, the higher its processing speed. We need to optimize power consumption with processing speed and therefore select the operating frequency accordingly.
There are two flavors for the Atmega16 microcontroller:
1. Atmega16 :- Operating frequency range is 0 to 16 MHz.
two. Atmega16L :- Operating frequency range is 0 to 8 MHz.
If we are using an 8 MHz crystal = 8 x 10 6 Hertz = 8 million cycles, then the AVR can execute 8 million instructions.
Naming convention.!
The NO refers to Atmel, the manufacturer, Mega means the microcontroller belongs to the MegaAVR category, 16 means the controller memory, which is 16 KB.
Convenção de nomenclatura do microcontrolador AVR
Figure 4: AVR microcontroller naming convention

Architecture Diagram: Atmega16

The following points explain the building blocks of the Atmega16 Architecture :
· I/O Ports : Atmega16 has four (PORT, PORTB, PORTC and PORTD) 8-bit input-output ports.
· Internal Calibrated Oscillator : The Atmega16 is equipped with an internal oscillator to drive its clock. By default, the Atmega16 is configured to operate with a calibrated internal oscillator of 1 MHz. The maximum frequency of the internal oscillator is 8Mhz. Alternatively, the ATmega16 can be operated using an external crystal oscillator with a maximum frequency of 16MHz. In this case you need to modify the fuse bits. (Fuse Bits will be explained in a separate tutorial).
Diagrama de blocos explicando a arquitetura AVR
· Figure 5: Block diagram explaining the AVR architecture

ADC Interface : Atmega16 is equipped with an 8-channel ADC ( Analog to Digital Converter ) with 10-bit resolution. The ADC reads the analog input, for example a sensor input, and converts it into digital information that is understandable by the microcontroller.
· Timers/Counters : Atmega16 consists of two 8-bit and one 16-bit timer/counters. Timers are useful for generating precision actions, for example creating delays between two operations.
· Watchdog Timer : Watchdog timer is present with internal oscillator. The Watchdog timer continuously monitors and resets the controller if the code is stuck in any execution action for more than a set time interval.
· Interrupts : The Atmega16 consists of 21 interrupt sources, of which four are external. The rest are internal interrupts that support peripherals like USART, ADC, Timers etc.
· USART : Universal synchronous and asynchronous interface receiver and transmitter is available for interfacing with external device capable of serial communication (bit-by-bit data transmission).
·

Continued Architecture

General Purpose Registers : The Atmega16 is equipped with 32 general purpose registers that are coupled directly to the Arithmetic Logic Unit (ALU) of the CPU.
· Memory : Atmega16 consists of three different memory sections:
1. Flash EEPROM : Flash EEPROM or simple flash memory is used to store the program dumped or written by the user in the microcontroller. Can be easily electrically erased as a single unit. Flash memory is non-volatile, meaning it retains the program even if the power is cut. Atmega16 is available with 16 KB of system-programmable Flash EEPROM.
two. Byte-addressable EEPROM : This is also a non-volatile memory used to store data like values ​​of certain variables. Atmega16 has 512 bytes of EEPROM, this memory can be useful for storing the lock code if we are designing an application such as electronic lock.
3. SRAM : Static random access memory, this is the volatile memory of the microcontroller, i.e. data is lost as soon as the power is turned off. Atmega16 is equipped with 1 KB of internal SRAM. A small portion of SRAM is reserved for general-purpose registers used by the CPU and another portion for the microcontroller's peripheral subsystems.
· ISP : The AVR family of controllers has a programmable Flash Memory system that can be programmed without removing the IC from the circuit, the ISP allows you to reprogram the controller while it is in the application circuit.
· IPS : Serial Peripheral Interface , The SPI port is used for serial communication between two devices on a common clock source. The data transmission rate of SPI is higher than that of USART.
· TWI : Two-wire interface (TWI) can be used to configure a network of devices, many devices can be connected through the TWI interface forming a network, devices can transmit and receive simultaneously and have their own unique address.
· DAC : Atmega16 is also equipped with a Digital to Analog Converter (DAC) which can be used for reverse action performed by the ADC. DAC can be used when there is a need to convert a digital signal into an analog signal.

MegaAVR Family

Various MegaAVR series microcontrollers:
ATmega8 and Atmega32 are other members of the MegaAVR series controllers. They are quite similar to the ATmega16 in architecture. Low power version MegaAVR controllers are also available in markets. The following table shows the comparison between the different members of the MegaAVR family:
Part name
ROM
TO KNOCK
EEPROM
I/0 pins
Stopwatch
Interruptions
Voltage Operation
Operating frequency
Packaging
ATmega8
8 KB
1 KB
512B
23
3
19
4.5-5.5V
0-16MHz
28
ATmega8L
8 KB
1 KB
512B
23
3
19
2.7-5.5V
0-8MHz
28
ATmega16
16 KB
1 KB
512B
32
3
21
4.5-5.5V
0-16MHz
40
ATmega16L
16 KB
1 KB
512B
32
3
21
2.7-5.5V
0-8MHz
40
ATmega32
32 KB
2 KB
1 KB
32
3
21
4.5-5.5V
0-16MHz
40
ATmega32L
32 KB
2 KB
1 KB
32
3
21
2.7-5.5V
0-8MHz
40

Conteúdo Relacionado

What is the role of automotive sensors in modern vehicles?
A network of sensors is embedded in every vehicle,...
How to choose an e-bike controller
The motor controller is one of the most important...
How to Troubleshoot Common ESP32-CAM Problems
ESP32-CAM is a compact camera module that combines the...
A guide to USB standards from 1.0 to USB4
A evolução dos padrões USB foi fundamental para moldar...
Schurter aprimora série de seletores de tensão com revestimento prateado
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A interface serial PCI fornece conectividade confiável em ambientes extremos
A Sealevel Systems anuncia o lançamento da Interface Serial...
STMicroelectronics expande portfólio de conversão de energia com diodos Trench Schottky de 100 V
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
O que são Sistemas Globais de Navegação por Satélite (GNSS) e como são usados?
Determinar uma localização precisa é necessário em várias indústrias...
O conversor GaN de 50 W da STMicroelectronics permite projetos de energia de alta eficiência
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
Samsung e Red Hat farão parceria em software de memória de próxima geração
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
Primeiro MPU single-core com interface de câmera MIPI CSI-2 e áudio
O mercado embarcado tem uma necessidade de soluções de...
Fluency decoding in induction motor for better performance
You have probably come across the term ' drag...
Understanding Support Insulators in Electrical Systems
You probably have a support insulator if you've noticed...
Explore Stay Insulator – safety, installation and maintenance
You've probably seen stand an insulator sit on power...
More safety and efficiency with the shackle isolator
You've probably seen shackle insulators enthroned on electricity poles,...
Discover the power of latching relays for energy efficiency and more
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.