1AVR Microcontrollerand AssemblyLanguageLecture# 02Microprocessor System and InterfacingCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
2Lecture Objectives About AVR Microcontroller Microcontroller Architecture Assembly LanguageCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
3Harvard and Von Neumann Architectures A Von Neumann architecture has only one bus which is usedfor both data transfers and instruction fetches Harvard architecture has separate data and instructionbusses, allowing transfers to be performed simultaneously onboth busses.COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
4Microprocessors Amicroprocessorincorporatesthefunctionsofa computer's central processing unit (CPU) on asingle integrated circuit (IC), or at most a few integratedcircuits. It is a multipurpose, programmable device thataccepts digital data as input, processes it according toinstructions stored in its memory, and provides results asoutput. It is an example of sequential digital logic, as it has internalmemory. Microprocessors operate on numbers and symbolsrepresented in the binary numerical system. Examples Intel x86(286,386,486), Pentium series, MotorolaPower PC, Advance RISC Machine (ARM) Processor . Microprocessor might only include an arithmetic logicunit (ALU) and a control logic section.COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
5Microprocessors The ALU performs Arithmetic operations addition, subtraction,and logical operations AND or OR. Each operation of the ALU sets one or more flags in a statusregister, which indicate the results of the last operation (zerovalue, negative number, overflow. or others). Control Unit retrieves instruction operation codes frommemory, and initiates whatever sequence of operations of theALU required to carry out the instruction. A single operation code might affect many individual datapaths, registers, and other elements of the processor.COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
6Microprocessor A multi-core processor is simply a single chip containingmore than one processing cores. This effectively multiplies the processor'sperformance by the number of cores.potential Some components, such as bus interface and cache,may be shared between cores. The cores are physically very close to each other, theycan communicate with each other much faster thanseparate processors in a multiprocessor system, whichimproves overall system performance.COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
7Microprocessor Microprocessor ArchitectureCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
8A ComparisonMicroprocessorCOMSATS University IslamabadMicrocontrollerDr. Sohaib Ayyaz Qazi
9Choosing a Microcontroller Microcontrollers are generally 8-bit. Each controller has a unique instruction set andregister set and are not compatible with oneanother. Criteria to choose microcontroller include: Meeting needs efficiently and cost effectively Speed, Packaging, Power Consumption, RAM and ROM,IO pins and timer, Cost per unit. Hardware and software development tools Availability and reliability of microcontroller sourcesCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
10AVR Microcontroller 8-bit single-chipArchitecturemicrocontrollerwithHarvard On-chip program ROM Data RAM EEPROM Timers I/O portsCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
11AVR Microcontroller Program ROM Used to store programs Size can vary from 1K to 256K AVR is the first microcontroller to use on-chip FlashmemoryCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
12AVR Microcontroller Data RAM and EEPROM Used for data storage It has general purpose registers, I/O memory andinternal SRAM 32 general purpose registers Size of SRAM and I/O memory size varies EEPROM stores critical data which does not need tobe changedCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
13AVR Microcontroller I/O Pins Normally 3 to 86 pins for I/O purpose Depends on package The package size varies from 8 to 100 pinsCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
14AVR Microcontroller Peripherals ADC Timers USART I2C SPICOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
15AVR Architecture and Programming General Purpose Registers AVR Data Memory Instruction with Data Memory AVR Status Register AVR Data Format and Directives AVR Assembly Programming Assembling an AVR Program Program Counter and Program ROM spaceCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
16AVR Architecture and Programming General Purpose Registers (GPRs) Many registers to store data Store information temporarily which is byte of data or addresspointing to data In AVR there are 32 GPRs Located at lowest of memory locations (address from 0x0000to 0x001FD7D6D5D4 R0 D3D2D1D0D7D6D5D4 R1 D3D2D1D0D7D6D5D4 R2 D3D2D1D0D7D6D5D4 R31 D3D2D1D0COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
17AVR Architecture and Programming GPRs – LDI Instruction Copies 8-bit data into general purpose registers LDI Rd, KK is an 8-bit value, Rd is any of the R16 to R31 registersLDI loads right operand in left operandI stands for “immediate”, provide data immediately Remember that To present a number in hex either use or 0x before anynumber. Otherwise it will be treated as a decimal. If values from 0 to F are moved then rest of the bits will betreated as zeros. If a larger value greater than 255 is moved then it will causean errorCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
18AVR Architecture and Programming GPRs – LDI Instruction – ExampleLDI R20, 0x20; load R20 with 0x20LDI R31, 0x87; load R31 with 0x87LDI R25, 0x79; load R25 with 0x79LDI R25, 23 ; What is the value of R25?LDI R31, 86; What is the value of R31?COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
19AVR Architecture and Programming GPRs – ADD Instruction Adds the value of one register to the other ADD Rd, RrAdds Rr with Rd and stores value in RdCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
20AVR Architecture and Programming GPRs – ADD Instruction - Example Add two numbers 0x25 and 0x34LDI R16, 0x25LDI R17, 0x34ADD R16, R17What is the value of R16?What is the value of R17?COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
21AVR Architecture and Programming The AVR Data Memory Used to store data Divided in three parts GPRs I/O Memory SRAMCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
22AVR Architecture and Programming The AVR Data Memory - GPRs 32 bytes of memory Address are from 00 - 1FCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
23AVR Architecture and Programming The AVR Data Memory – I/O Memory Used to control microcontroller peripherals such as Status registers Timers Serial Communication I/O Ports ADC Memory depends on number of pins available At-least 64 bytes of memory is available for all AVRsCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
24AVR Architecture and Programming The AVR Data Memory – SRAM Store any 8-bit wide data Accessed by address directly Total memory size is sum of all memoriesData 435264 160409632ATmega2560870464 416819232EEPROM memory is used to store data permanently. It is noterased when power is offCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
25AVR Architecture and Programming Instruction with Data Memory Instructions can be used to access different locations of datamemoryCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
26AVR Architecture and Programming Instruction with Data Memory – STS STore direct to data Space STS K, RrK is address location between 0x0000 and 0xFFFFRr to take data from To copy contents of GPRs into an address location in dataspace This location can be any part of data space available ExampleSTS 0x230, R25What will happen when this instruction is executed?COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
27AVR Architecture and Programming Instruction with Data Memory – STS – Class ExerciseLDI R20, 0x99STS 0x200, R20STS 0x201, R20STS 0x202, R20STS 0x203, R20What will be the result of these instructions ? Anyone who can fillthis table ?AddressData0x2000x2010x2020x203COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
28AVR Architecture and Programming Instruction with Data Memory - LDS Load Direct from data Space LDS Rd, KRd data location to be storedK is address between 0x0000 and 0xFFFF Instruction tells CPU to copy one byte of data from addresslocation This location can be any part of data space available ExampleLDS R5, 0x200What will be the result of this instruction ?COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
29AVR Architecture and Programming Instruction with Data Memory – LDS – Class Exercise Load two numbers in two GPRs Store these numbers at locations 0x300 and 0x302 Add two numbers located at 0x300 and 0x302R0R1Addr 300Addr 302Before LDS R0, 0x300?1213After LDS R0, 0x30012?1213After LDS R1, 0x30212131213ADD R1, R025131213COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
30AVR Architecture and Programming Instruction with Data Memory – STS – Class Exercise Put 0x45 to Ports B, C. The addresses of port B, C and D is 0x38,0x35, 0x32COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
31Home Task # 1Load R16 with value from address 55H and R20with value 0x23. Add these values and send toPort D with address 0x32.COMSATS University IslamabadDr. Sohaib Ayyaz Qazi
32Home Assignment TaskComplete all “Review Questions” in the book relatedto the topics covered for AVR Architecture andAssembly LanguageCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
33Assignments Write Lectures in your own words Include any example and exercise performed duringlecture Include couple of more exercises/questions related tothe topics in class. (Be creative – You will get bonusMarks for it) Send notes of both lectures by Saturday NightCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
34Lecture Summary Hardvard vs von Neumann Architecture Microcontroller vs Microprocessor AVR Microcontroller Architecture General Purpose Registers The AVR Data Memory Instructions with Data MemoryCOMSATS University IslamabadDr. Sohaib Ayyaz Qazi
AVR Microcontroller Architecture General Purpose Registers The AVR Data Memory Instructions with Data Memory COMSATS University Islamabad Dr. Sohaib Ayyaz Qazi 34. Title: CALL
AVR Basics The AVR microcontrollers are divided into three groups: 1. tiny AVR 2. AVR (Classic AVR) 3. mega AVR 4. xmega AVR The difference between these devices lies in the available features. The tinyAVR μC are usually devices with lower pin-count or a reduced feature set compared to the mega & xmega AVR's. All AVR devices have identical
The AVR 3700/AVR 370 7.2-channel and AVR 2700/AVR 270 7.1-channel digital audio/ video receivers continue this tradition with some of the most advanced audio and video processing capabilities yet, and a wealth of listening and viewing options. To obtain the maximum enjoyment from your new receiver, please read this manual and
the Avr 3700/Avr 370 7.2-channel and Avr 2700/Avr 270 7.1-channel digital audio/ video receivers continue this tradition with some of the most advanced audio and video processing capabilities yet, and a wealth of listening and viewing options. to obtain the maximum enjoyment from your new receiver, please read this manual and
download the AVR 3650, AVR 365, AVR 2650, AVR 265 Owner’s Manual. Place the Receiver Place the receiver on a firm and level surface. Be certain that the surface and any mounting hardware can support the receiver’s weight. Provide proper space above and below the receiver for ventilation. If you install the receiver
The Bridge II-ready Harman Kardon receivers, and the Harman Kardon DMC 1000 digital media center. As of the printing of this manual, these models include: Audio playback only: AVR 140, AVR 240, AVR 340, AVR 145, AVR 245, AVR 445, AVR 645, AVR 745, HK 3490
avr 3700 и avr 2700 предназначены для использования с переменным током напряжением 120 В. avr 370 и avr 270 предназначены для использования с переменным током напряжением 220 – 240 В. Подключение к напряжению,
die receiver avr 3700 und avr 2700 sind für den Betrieb mit 120 v Wechselstrom (ac) ausgelegt. die receiver avr 370 und avr 270 sind für den Betrieb mit 220-240 v Wechselstrom (ac) ausgelegt. der anschluss an ein Stromnetz, das nicht dem Stromnetz entspricht, für das ihr receiver gebaut wurde, kann zu einem Sicherheits- und
Устройства avr 3650 и avr 2650 были сконструированы для использования с источником сетевого напряжения 120 В переменного тока. Устройства avr 365 и avr 265 были сконструированы для исполь-