Avr Architecture and Assembly Language Programming
Avr Architecture and Assembly Language Programming
AVR:AVR không phải là một chữ viết tắt chính thức, nhưng thường được cho là bắt nguồn từ tên của hai nhà
sáng lập Alf-Egil Bogen và Vegard Wollan, cùng với chữ "R" có thể đại diện cho "RISC" (Reduced Instruction
Set Computer), một kiến trúc tập lệnh mà vi điều khiển này sử dụng.
2.1 Overview Atmel Atmega32 highlights
An 8-bit microcontroller featuring:
3
Harvard Architecture in AVR
EEPROM TIMERS
Progra GPRs SRAM
m Flash
ROM CPU
Data bus
Address bus
Data bus
Address bus Control bus
Control bus
Interrup Ports Other
t Units Peripherals
On Chip
Debugger
5
Atmel Atmega32
Central Processing Unit
Arithmetic Logic Unit (ALU)
performs the actual arithmetic,
logical, and bit-functions
Memory – SRAM, EEPROM, Flash
Clock circuit – internal/external
I/O – Input/Output; video, serial,
parallel, USB, SCSI, etc.
2.2 Memory (Bộ nhớ của VĐK AVR)
3 Separate on-chip memories
8 bits of register (MSB : most significant bit [D7]; LSB: Least significant bit[D0))
D7 D6 D5 D4 D3 D2 D1 D0
2.4 Special-purpose Registers
Special-purpose Registers can also be operated upon directly by
the ALU (with certain specific instructions)
Stack pointer (SP, 16-bit)
Stores return address of
subroutine/interrupt calls
Storing temporary data
and local variables
11
2.5 The machine-instruction is executed by the
Central Processing Unit
• When the device is powered-on, the Program Counter is
set to 0.
• The instruction at the location in Flash Memory at the
address indicated by the Program Counter is fetched
and placed in the Instruction Register
• The opcode and operands within the instruction are
extracted by the Instruction Decoder
• The control lines from the I.D. activate the particular
circuitry within the ALU that is capable of processing that
particular opcode. The ALU executes the instruction.
• The Program Counter is automatically incremented and
the cycle repeats.
12
Instruction execution timing
13
2.6 Overview assembly language instructions
• Describing operations in a
seminatural language
• Increase the portability
High- Levels Language of the code
• One line may involve many
low-level operations
• Ex: C,C++
• Tied to the specifics of the
underlying machine
Three Levels of Languages Assembly Languages • Commands and names to
make the code readable and
writeable by humans
• Hand-coded assembly code
may be more efficient
Machine Languages
14
2.6 Overview assembly language instructions
17
Yet another Development System: AVRStudio
18
Quick answer!