AVR CPU Core & 8 bit AVR Instruction Set

Slides:



Advertisements
Similar presentations
Machine cycle.
Advertisements

COMP3221: Microprocessors and Embedded Systems
Parul Polytechnic Institute
Computer Organization and Architecture
Processor Function Topic 3.
Processor System Architecture
S. Barua – CPSC 240 CHAPTER 5 THE LC-3 Topics Memory organization Registers Instruction set Opcodes.
CHAPTER 4 COMPUTER SYSTEM – Von Neumann Model
Memory - Registers Instruction Sets
Stored Program Concept: The Hardware View
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
COMP3221: Microprocessors and Embedded Systems--Lecture 9 1 COMP3221: Microprocessors and Embedded Systems Lecture 9: Data Transfer Instructions
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
Gursharan Singh Tatla Block Diagram of Intel 8086 Gursharan Singh Tatla 19-Apr-17.
Architecture of the MSP430 Processor. Central Processing Unit Program Counter (PC) - Contains the address of the next instruction to be executed. The.
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
Atmega32 Architectural Overview
Basic Operational Concepts of a Computer
AVR Microcontrollers.
Computer Engineering AddSub page 1 Basic Building Blocks Multiplexer + Demultiplexer Adder.
Introduction to AVR Chapter 1
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
Instruction Set Architecture The portion of the machine visible to the programmer Issues: Internal storage model Addressing modes Operations Operands Encoding.
Execution of an instruction
Chapter 5 The LC Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization.
Computer Architecture Lecture 03 Fasih ur Rehman.
The von Neumann Model – Chapter 4 COMP 2620 Dr. James Money COMP
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Computer Architecture Lecture 4 by Engineer A. Lecturer Aymen Hasan AlAwady 17/11/2013 University of Kufa - Informatics Center for Research and Rehabilitation.
Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.
PART 4: (1/2) Central Processing Unit (CPU) Basics CHAPTER 12: P ROCESSOR S TRUCTURE AND F UNCTION.
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
COMP3221: Microprocessors and Embedded Systems--Lecture 10 1 COMP3221: Microprocessors and Embedded Systems Lecture 10: Shift and Bit-set Instructions.
An Adder A Subtractor. A and B are the inputs of the adder/ subtractor R is the output of the adder/ subtractor F is the control to tell it to add or.
Processor Organization
Computer Organization Instructions Language of The Computer (MIPS) 2.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
AVR Architecture Prepared By: Avdhesh Soni ( ) Sarthak Patel ( ) Akshay Parekh ( ) Fenil Sachla ( ) Guided.
Vadodara Institute of Engineering Subject: Microcontroller interfacing Prepared by: Bipin Malani ( ) Vishwa Pandit ( ) Branch : Electronics.
“Atmega32 Architectural Overview” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Parihar Shipra A Guided By:-
“ INSTRUCTIONS SET OF AVR MICROCONTROLLER ” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Abhishek Lakhara
Seminar On 8085 microprocessor
COMP2121: Microprocessors and Interfacing
Atmega32 Architectural Overview
C. K. Pithawalla College of Engineering and Technology, Surat
Overview of Architecture Assembly Programming Concepts
MCI PPT AVR MICROCONTROLLER Mayuri Patel EC-1 5th sem
ECE 3430 – Intro to Microcomputer Systems
Computer Architecture
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Processor Organization and Architecture
Chapter 5 The LC-3.
Number Representations and Basic Processor Architecture
Memories.
Introduction to Assembly Chapter 2
Central Processing Unit
Architectural Overview
Processor Organization and Architecture
Microprocessors And Microcontrollers
Addressing Modes Register Direct, with 1 and 2 registers I/O Direct
Introduction to Assembly Chapter 2
Unit 12 CPU Design & Programming
Computer Architecture
Basic Building Blocks Multiplexer Demultiplexer Adder +
Basic Building Blocks Multiplexer Demultiplexer Adder +
Introduction to Assembly Chapter 2
Computer Operation 6/22/2019.
Embedded Systems- Instruct set
Embedded Systems- Micro-controller
Presentation transcript:

AVR CPU Core & 8 bit AVR Instruction Set

안철수 KAIST 석좌교수 "개발자가 성공하는 길" http://www.devmento.co.kr/devmain/ucc/ucc/ucc_detail.jsp?cate_code=ADAFAA&dataSeq=76&main_id=SUCC1W001

Block Diagram of the AVR Architecture

AVR Architecture Flash program memory (16bit) Data Memory (8 bit) 16 bit x 216 = 2 byte x 64 k = 128 kbyte Program code가 저장되는 곳 Data Memory (8 bit) 범용 register : 32 byte I/O register : 64 byte Ext I/O register : 160 byte SRAM : 4096byte 변수가 저장되는 곳 PC : Program Counter address of the instruction being executed

Program / Compile / Execution Program 작성 -> C code 생성 Compile -> hex code 생성 hex code : download 가 가능한 code machine code (opcode) : 실행 가능한 code assembly code : machine code의 의미 Execution start address of program code => PC Fetch : PC -> flash program memory => machine code -> IR PC = PC+1 (또는 PC+2) (IR : instruction register) Decode : instruction decode Register Operand Fetch ALU Operation Execute Result Write Back goto Fetch

Instruction Execution an element of an executable program a single operation of a processor Parallel Instruction Fetches and Instruction Executions Single Clock Cycle Execution : Harvard architecture clkCPU : system clock Atmega 128 : 16MHz 가능, XTAL1 pin으로 공급 실습 kit : 7.3728 MHz (확인요)

Single Cycle ALU Operation (in AVR) Execution Cycle Execution Time 1/clkCPU clkCPU = 16 MHz ? clkCPU = 7.3728 MHz ?

8 bit AVR Instruction Set Operation Code + Operand Operation Code : ALU가 실행할 내용 Operand : ALU가 실행할 대상 Ex) ADC : Add with Carry ‘ADC R1, R2’ 의 opcode 는 ?

Operation Code의 유형 Arithmetic and Logic Branch Data Transfer 범용 레지스터간의 사칙연산과 로직 연산 ADC, AND, SUB, AND, OR, … Branch Change program counter : 다른 opcode위치로 이동 JMP, BRBC, … Data Transfer Load : SRAM등의 Data를 범용 Register로 이동 (LD, LDI, …) Store : 범용 Register의 값을 SRAM 등으로 이동 (ST, STD, …) Bit and Bit-Test Register의 특정 bit을 set(=‘1’)하거나 clear(=‘0’)으로 변경 SBI, CLI, …. MCU Control

Data Addressing Mode : Operand의 유형 Immediate actual operand Direct (absolute) address of operand Register Direct, I/O Direct, Data Direct Indirect Address that specifies (or points to ) operand Data Indirect, Data Indirect with Displacement, Data Indirect with Pre-Decrement, Data Indirect with Post-Increment

Example) Immediate Addressing ANDI – Logical AND with Immediate ANDI r17, $0F

Example) Register Direct Addressing

Example) Register Direct Addressing ADD – Add without Carry ADD r1, r2 ADD r28, r28

Example) I/O Direct Addressing IN - Load an I/O Location to Register IN r25, $16

Example) Data Direct Addressing LDS – Load Direct from Data Space LDS R25, $0100 2 word/2 cycle

Data Indirect X,Y,Z register 사용

Example) Data Indirect LD

Example) Data Indirect CLR R27 LDI R26,$60 LD R0,X+ LD R1,X LDI R26,$63 LD R2,X LD R3,–X

Status Register The Status Register contains information about the result of the most recently executed SREG 비트 설명 I Global Interrupt Enable T Bit Copy Storage H Half Carry Flag S Sign Bit V 2's Complement Overflow Flag N Negative Flag Z Zero Flag C Carry Flag

Status Register 비트 7(I : Global Interrupt Enable) : 전체 인터럽트를 허용하도록 설정하는 비트로 SEI 및 CLI 명령으로 이 비트를 제어할 수 있다. 비트 6(T : Bit Copy Storage) : BLD, BST 명령을 사용하여 어느 레지스터의 한 비트 값의 복사 가능. 비트 5(H : Half Carry Flag) : 산술연산의 가감산에서 비트3에서 올림수가 발생하면 1로 세트 BCD 연산에 사용 비트 4(S : Sign Bit) : 플랙 N과 V의 XOR(eXclusive OR)값으로 정수들의 크기를 판단에 사용.

Status Register 비트 3(V : 2's Complement Overflow Flag) : 2의 보수 연산에서 오버플로우를 표시한다. 비트 2(N : Negative Flag) : 연산 결과값의 최상위 비트가 1로 되어 2의 수 표현을 사용하는 경우 연산 결과가 음수임을 표시. 비트 1(Z : Zero Flag) : 연산 결과값이 0이 되었음을 표시. 비트 0(C : Carry Flag) : 연산으로 자리올림이나 자리내림이 발생하면 1로 세트 된다.

Status Register 모든 연산이 실행된 후에 SREG이 변경됨 예) ADD

★ JTAG Emulator JTAG (Joint Test Action Group) Testing PCBs by using the JTAG Boundary-scan capability Programming the non-volatile memories, Fuses and Lock bits On-chip debugging program download : JTAG emulator UART 통신 : ISP programmer

Instruction Example : int main(){ unsigned char *a,*b,*c; a = (unsigned char *)0x100; b = (unsigned char *)0x101; c = (unsigned char *)0x102; *c = *a + *b; return 0; }

Machine Code(Opcode) / Assembly Code Compile/Download 후 Debug메뉴의 ‘Start Debugging’ View 메뉴의 ‘Disassembler’ +0000005F: 91900100 LDS R25,0x0100 Load direct from data space +00000061: 91800101 LDS R24,0x0101 +00000063: 0F89 ADD R24,R25 Add without carry +00000064: 93800102 STS 0x0102,R24 Store direct to data space

Instruction Example : int main(){ unsigned int *a,*b,*c; a = (unsigned int *)0x100; b = (unsigned int *)0x101; c = (unsigned int *)0x102; *c = *a + *b; return 0; }

Machine Code(Opcode) / Assembly Code Program address Opcode Assembly Code

Instruction Example : int main(){ unsigned int *a,*b,*c; a = (unsigned int *)0x100; b = (unsigned int *)0x102; c = (unsigned int *)0x104; return 0; }

Machine Code(Opcode) / Assembly Code Program address Opcode Assembly Code

HEX File Compile 결과물의 하나 Project directory 아래 “default” 폴더 Intel Hex Format :100000000C9446000C945D000C945D000C945D0013 :100010000C945D000C945D000C945D000C945D00EC :100020000C945D000C945D000C945D000C945D00DC :100030000C945D000C945D000C945D000C945D00CC :100040000C945D000C945D000C945D000C945D00BC :100050000C945D000C945D000C945D000C945D00AC :100060000C945D000C945D000C945D000C945D009C :100070000C945D000C945D000C945D000C945D008C :100080000C945D000C945D000C945D0011241FBE67 …

Intel Hex Format :100000000C9446000C945D000C945D000C945D0013 : 10 0000

Intel Hex Format 8-bit 16-bit address code 0x0000 0C 0x0001 94 0x0002 46 0x0003 00 0x0004 0x0005 0x0006 5D 0x0007 0x0008 0x0009 0x000A 0x000B 16-bit Address code 0x0000 940C 0x0001 0046 0x0002 0x0003 005D 0x0004 0x0005