EE 308: Microcontrollers

Size: px
Start display at page:

Download "EE 308: Microcontrollers"

Transcription

1 EE 308: Microcontrollers Review Part I Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA February 15, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

2 Harvard Architecture overview data bus data bus Code memory control bus CPU control bus Data memory address bus Harvard architecture address bus Separate buses for accessing code and data Faster Less delays Requires more hardware Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

3 Data, address and control lines Data lines carry information in and out of the CPU. More lines results in faster data transfer but more complex and more expensive. Address lines identifies the devices and memory to be connected to the CPU Control lines control devices signals for read/write as directed by the CPU Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

4 Memory Register file: embedded in the CPU for fast operations Code memory: ROM typically flash Data memory: RAM typically SRAM Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

5 Addressing modes Immediate (single-register): operand is a register and may have a constant value as a second operand, e.g., NEG R18 ;negate the content of R18 LDI R19,0 x06 ;load 0x06 into R19 Register: two registers hold the data to be manipulated ADD R20, R23 ;add R23 to R20 and store the result in R20 Direct: operand is a memory location LDS R19,0 x560 ;load R19 with the content of mem loc 0x560 STS 0x40, R19 ;store R19 to data space location 0x40 Register indirect: operand is a register but in points to the memory location LDI XL,0 x30 ;load R26 (low byte of X) with 0x30 LDI XH,0 x01 ;load R27 (high byte of X) with 0x01 LD R18,X ;load R18 with content of memory 0x130 Auto-increment/auto-decrement: content of register is pre- or post- incremented/decremented after/before memory access LD Rn,X+ ;load Rn with content pointed to by X then inc X LD Rn,-X ;decrement X then load Rn by contented pointed to by new X Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

6 Arithmetic Logic Unit (ALU) A[n 1 : 0] B[n 1 : 0] Takes two inputs Status Performs arithmetic and logic operations Op Code ALU Status Result Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

7 Memory map Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

8 I/O space I/Os and peripherals are placed in I/O space I/O addresses are offset from memory address by 0x20 I/O registers in the range 0x00 to 0x1F are directly bit accessible IN and OUT commands must use addresses in the range 0x00 to 0x3F When using LD and ST commands I/O registers are addressed as data space and therefore 0x20 must be added to their addresses Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

9 Assembly language Assembly language consists of, instructions referred to as mnemonics, directives and labels.. include " m1284def. inc " ldi r16, hi8 ( RAMEND ) out SPH, r16 ldi r16, lo8 ( RAMEND ) 5 out SPL, r16 ;initialize stack pointer sbi DDRC, 0 ;set bit 0 of ddrc here : sbi PORTC, 0 10 call delay ;call delay subroutine cbi PORTC, 0 call delay rjmp here 15 delay : ldi r20, 255 dl1 : dec r20 brne dl1 ret Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

10 Assembly language Assembly language consists of, instructions referred to as mnemonics, directives and labels.. include " m1284def. inc " ldi r16, hi8 ( RAMEND ) out SPH, r16 ldi r16, lo8 ( RAMEND ) 5 out SPL, r16 ;initialize stack pointer sbi DDRC, 0 ;set bit 0 of ddrc here : sbi PORTC, 0 10 call delay ;call delay subroutine cbi PORTC, 0 call delay rjmp here 15 delay : ldi r20, 255 dl1 : dec r20 brne dl1 ret Directive Label Comment Instruction Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

11 Manipulating the stack PUSH instruction: stores onto the stack POP instruction: removes content from the stack Data is stored where the SP is pointing and then it is decremented Last-in-first-out Some microcontrollers increment the SP rather than decrement Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

12 Initializing the stack pointer When the program starts the stack pointer is set to zero and will need to be initialized so that it points to the end of the RAM. As different microcontrollers have different size RAM we use RAMEND to represent the address of the last RAM location Stack pointer is initialized as follows LDI r16, hi8 ( RAMEND ) ;load SPH OUT SPH, r16 LDI r16, lo8 ( RAMEND ) ;load SPL OUT SPL, r16 SP could be decremented up to the point above 0x100 for the ATmega1284 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

13 Program memory constant addressing 0x0001 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

14 Program memory constant addressing 2-bytes 0x0001 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

15 Program memory constant addressing 2-bytes 0x0000 0x0001 0x0001 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

16 Program memory constant addressing 2-bytes 0x0000 0x0010 0x0001 0x0011 0x0001 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

17 Program memory constant addressing 2-bytes 0x0000 0x0010 0x0001 0x0011 0x0001 The byte address of each location is the program address multiplied by 2 To access the high byte the Z register showed have a zero in the LSB To access the low byte the Z register showed have a one in the LSB GNU Assembler handles this natively In Atmel ASM2 you will have to multiply the desired address by 2 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

18 Branching Write an assembly program that implements the following if (T >= 90) F = H ; else if (T > 40) F = N ; else F = C ; Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

19 Branching Write an assembly program that implements the following if (T >= 90) F = H ; else if (T > 40) F = N ; else F = C ; Assuming that the value of T is loaded into r20 and F is r21 cpi r20,90 brlt elseif ldi r21, H rjmp end elseif : cpi r20,40 brlt else ldi r21, N rjmp end else : ldi r21, C end : Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

20 Branching Write an assembly program that implements the following for (i =0; i <10; i ++) y = i /2; Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

21 Branching Write an assembly program that implements the following for (i =0; i <10; i ++) y = i /2; Assuming that the value of i is loaded into r20 and y is r21 for : cpi r20, 10 brge end mov r21, r20 asr r21 inc r20 jmp for end : Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

22 General digital I/O details Typically there are three main registers that control digital I/O ports Data Direction Register (DDRx): Controls whether each pin of a port x is an output (value of 1) or input (value of 0). Port Register (PORTx): Setting the bit in this register corresponds to sending a high value to the pin. Clearing a bit corresponds to setting the pin to low. Reading the PORTx provides the value that was written to it. Port Input Register (PINx): Generally used for reading the value of a pin that was set as an input. At reset all port are configured as input, i.e., DDRx is set to zero Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

23 Pull-up resistors What will happen if an input pin is connected to a switch that is connected to ground? Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

24 Pull-up resistors What will happen if an input pin is connected to a switch that is connected to ground? If the switch is not pressed the input value to the pin is floating Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

25 Pull-up resistors What will happen if an input pin is connected to a switch that is connected to ground? If the switch is not pressed the input value to the pin is floating If the switch is pressed the pin is shorted and must provide lots of current Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

26 Pull-up resistors What will happen if an input pin is connected to a switch that is connected to ground? If the switch is not pressed the input value to the pin is floating If the switch is pressed the pin is shorted and must provide lots of current Need a pull-up resistor Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

27 Using I/O port example Given and alarm system with an indicator if it is armed and indicator if a door is open. If the system is armed turn on an LED. If the system is armed and a door opens sound the alarm. Only pins 0, 1, 6 and 7 of port A are available. Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

28 Using I/O port example - solution Make pins 0 and 7 an input to represent the status of the system and the door, respectively. Make pins 1 and 6 of port A an output to control the LED and the siren, respectively. Don t change any of the other pins. Keep checking pin 0, if it goes high send a high on pins 1 and check pin 7. If pin 7 goes high output a high on pin 6. Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

29 Using I/O port example - solution Make pins 0 and 7 an input to represent the status of the system and the door, respectively. Make pins 1 and 6 of port A an output to control the LED and the siren, respectively. Don t change any of the other pins. Keep checking pin 0, if it goes high send a high on pins 1 and check pin 7. If pin 7 goes high output a high on pin 6. in r16, DDRA in r17, PORTA ori r16, (1<< PA1 ) (1 < < PA6 ) andi r16, ~((1 < < PA0 ) (1 < < PA7 )) andi r17, ~((1 < < PA1 ) (1 < < PA6 )) out PORTA, r17 out DDRA, r16 l1: sbis PINA, 0 rjmp l1 sbi PORTA,1 l2: sbis PINA, 7 rjmp l2 sbi PORTA,6 l3: rjmp l3 Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

30 Generating a square wave example. include " m1284def. inc " ldi r16, hi8 ( RAMEND ) out SPH, r16 ldi r16, lo8 ( RAMEND ) 5 out SPL, r16 ;initialize stack pointer sbi DDRC, 0 ;set bit 0 of ddrc here : sbi PORTC, 0 10 call delay ;call delay subroutine cbi PORTC, 0 call delay rjmp here 15 delay : ldi r20, 255 dl1 : dec r20 brne dl1 ret Aly El-Osery (NMT) EE 308: Microcontrollers February 15, / 19

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Introduction to the Assmbly Language Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 25, 2018 Aly

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers AVR Architecture Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 23, 2018 Aly El-Osery (NMT) EE 308:

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Introduction Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 6, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Assmbly Language Part I Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 30, 2018 Aly El-Osery (NMT)

More information

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation 2 Atmel AVR 8-bit RISC architecture

More information

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation 2 Atmel AVR 8-bit RISC architecture

More information

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming ICT 6641: Advanced Embedded System Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming Prof. S. M. Lutful Kabir Session: April, 2011 Review on Lecture-1 Three parts of a computer : CPU, Memory

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Timers Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA April 2, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

AVR ISA & AVR Programming (I)

AVR ISA & AVR Programming (I) AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo Week 1 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation Week 1 2 1 Atmel AVR 8-bit

More information

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs

More information

Module 2: Introduction to AVR ATmega 32 Architecture

Module 2: Introduction to AVR ATmega 32 Architecture Module 2: Introduction to AVR ATmega 32 Architecture Definition of computer architecture processor operation CISC vs RISC von Neumann vs Harvard architecture AVR introduction AVR architecture Architecture

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Interrupts Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA March 1, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD A. Assembly Language Programming Programming of a computer system: Machine code direct execution Assembly language tool: assembler High level programming language tool: interpreter tool: compiler Programming

More information

COMP2121: Microprocessors and Interfacing. I/O Devices (II)

COMP2121: Microprocessors and Interfacing. I/O Devices (II) COMP2121: Microprocessors and Interfacing I/O Devices (II) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Overview Keyboard LCD (Liquid Crystal Display) 2 2 Input Switches (1/2)

More information

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing Interfacing Lecture 9: Program Control Instructions http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 1, 2006 Program control instructions in AVR Stacks Overview Sample AVR assembly programs

More information

COMP2121: Microprocessors and Interfacing. I/O Devices (I)

COMP2121: Microprocessors and Interfacing. I/O Devices (I) COMP2121: Microprocessors and Interfacing I/O Devices (I) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Overview I/O Ports AVR Ports 2 2 What is I/O? I/O is Input or Output (Input/Output).

More information

ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Solution Set #2

ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Solution Set #2 ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Set #2 1- Consider the internal structure of the pseudo-cpu discussed in class augmented with a single-port register file (i.e.,

More information

By: Dr. Hamed Saghaei

By: Dr. Hamed Saghaei By: Dr. Hamed Saghaei The AVR RISC Microcontroller supports powerful and efficient addressing modes for access to the program memory (Flash) and data memory (SRAM). This section describes the different

More information

IAS0430 MICROPROCESSOR SYSTEMS

IAS0430 MICROPROCESSOR SYSTEMS IAS0430 MICROPROCESSOR SYSTEMS Fall 2018 Arduino and assembly language Martin Jaanus U02-308 martin.jaanus@ttu.ee 620 2110, 56 91 31 93 Learning environment : http://isc.ttu.ee Materials : http://isc.ttu.ee/martin

More information

Programming Microcontroller Assembly and C

Programming Microcontroller Assembly and C Programming Microcontroller Assembly and C Course Number CLO : 2 Week : 5-7 : TTH2D3 CLO#2 Student have the knowledge to create basic programming for microcontroller [C3] Understand how to program in Assembly

More information

Input/Output Devices. Lecturer: Sri Parameswaran Notes by: Annie Guo

Input/Output Devices. Lecturer: Sri Parameswaran Notes by: Annie Guo Input/Output Devices Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview Input devices Input switches Basics of switches Keypads Output devices LCD 2 Input Switches Most basic binary input

More information

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up

More information

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017 Objectives The AVR microcontroller and embedded systems using assembly and c I/O Ports in AVR List all the ports of the AVR microcontroller Describe the dual role of the AVR pins Code assembly language

More information

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100) (Revision-10) FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100) PART-A (Maximum marks : 10) I. Answer all

More information

AVR Microcontrollers Architecture

AVR Microcontrollers Architecture ก ก There are two fundamental architectures to access memory 1. Von Neumann Architecture 2. Harvard Architecture 2 1 Harvard Architecture The term originated from the Harvard Mark 1 relay-based computer,

More information

Using SRAM in AVR assembler language

Using SRAM in AVR assembler language Using SRAM in AVR assembler language All AVR-type MCUs have static RAM (SRAM) on board. Only very simple assembler programs can avoid using this memory space by putting all info into registers. If you

More information

CN310 Microprocessor Systems Design

CN310 Microprocessor Systems Design CN310 Microprocessor Systems Design Instruction Set (AVR) Nawin Somyat Department of Electrical and Computer Engineering Thammasat University Outline Course Contents 1 Introduction 2 Simple Computer 3

More information

COMP2121 Experiment 4

COMP2121 Experiment 4 COMP2121 Experiment 4 1. Objectives In this lab, you will learn AVR programming on Parallel input/output; Some typical input/output devices; and Interrupts 2. Preparation Before coming to the laboratory,

More information

Lecture 20: AVR Programming, Continued. AVR Program Visible State (ones we care about for now)

Lecture 20: AVR Programming, Continued. AVR Program Visible State (ones we care about for now) 18 100 Lecture 20: AVR Programming, Continued S 15 L20 1 James C. Hoe Dept of ECE, CMU April 2, 2015 Today s Goal: You will all be ace AVR hackers! Announcements: Midterm 2 can be picked up in lab and

More information

Microprocessors & Interfacing

Microprocessors & Interfacing Lecture Overview Microprocessors & Interfacing Input/Output Devices Input devices Input switches Basics of switches Keypads Output devices LCD Lecturer : Dr. Annie Guo S2, 2008 COMP9032 Week8 1 S2, 2008

More information

;Compiler Options.NOLIST.INCLUDE "C:\Program Files (x86)\atmel\avr Tools\AvrAssembler2\Appnotes\m8515def.inc"

;Compiler Options.NOLIST.INCLUDE C:\Program Files (x86)\atmel\avr Tools\AvrAssembler2\Appnotes\m8515def.inc ;* CharTest.asm ;* ;* Created: 28/06/2017 9:37 p.m. ;* Author: ob1 ;ST7820 128 x 64 graphics mode character display 8 lines x 21 characters ;Modification and redistribution under provisions of GNU general

More information

CHW 469 : Embedded Systems

CHW 469 : Embedded Systems CHW 469 : Embedded Systems Instructor: Dr. Ahmed Shalaby http://bu.edu.eg/staff/ahmedshalaby4# I/O Ports in AVR The AVR microcontroller and embedded systems using assembly and c Topics AVR pin out The

More information

APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET

APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET Other documents that are referred within this document are located at the link https://www.dropbox.com/sh/s16jri4eol3agl5/aaazn_w3p7fodjs-wi-xcenqa?dl=0 The ATmega32/ATmega2A

More information

Microcontroller VU

Microcontroller VU 182.694 Microcontroller VU Martin Perner SS 2017 Featuring Today: A Deep Look into the Processor Core Getting Code onto the Microcontroller Chip Weekly Training Objective This week 1.2 Board test 2.1.1

More information

Microcontrollers. Microcontroller

Microcontrollers. Microcontroller Microcontrollers Microcontroller A microprocessor on a single integrated circuit intended to operate as an embedded system. As well as a CPU, a microcontroller typically includes small amounts of RAM and

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Serial Perpherial Interface (SPI) Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA April 9, 2018 Aly El-Osery

More information

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1 Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University What is Assembly Language? Assembly language is a programming language

More information

AVR Subroutine Basics

AVR Subroutine Basics 1 P a g e AVR Subroutine Basics READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 3: Branch, Call, and Time Delay

More information

Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming

Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming Prof. Ben Lee Oregon State University School of Electrical Engineering and Computer Science Chapter Goals Understand how to program

More information

EECS 150 Homework 11 Solutions Fall 2008

EECS 150 Homework 11 Solutions Fall 2008 The first three questions concern 8, 16, and 32 bit microcontroller chips that all have family members available for under $1. The files referenced are available at: http://www.eecs.berkeley.edu/~pister/150fa08

More information

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration Features Utilizes the AVR Enhanced RISC Architecture 89 Powerful Instructions - Most Single Clock Cycle Execution 1K bytes of In-System Reprogrammable Downloadable Flash - SPI Serial Interface for Program

More information

TYPES OF INTERRUPTS: -

TYPES OF INTERRUPTS: - There are 3 types of interrupts. TYPES OF INTERRUPTS: - External Interrupts. Internal Interrupts. Software interrupts. Hardware Interrupts (1) External interrupts come from I/O devices, from a timing device

More information

8-bit Microcontroller with 4K Bytes In-System Programmable Flash. ATtiny40. Preliminary

8-bit Microcontroller with 4K Bytes In-System Programmable Flash. ATtiny40. Preliminary Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 54 Powerful Instructions Most Single Clock Cycle Execution 16 x 8 General Purpose Working Registers Fully Static

More information

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory Today s Menu Methods >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory Look into my See examples on web-site: ParamPassing*asm and see Methods in Software and

More information

ATmega128 Assembly Language Programming

ATmega128 Assembly Language Programming 마이크로프로세서응용 7 ATmega128 Assembly Language Programming Assembly Language g Field Delimiter Field structure a space or colon after a label a space after the operation code a comma between operands in the

More information

Gates and flip-flops: glue logic, simple FSMs, registers Two-level PLDs: FSMs, muxes, decoders. Programmable logic devices (CSE370, CSE467)

Gates and flip-flops: glue logic, simple FSMs, registers Two-level PLDs: FSMs, muxes, decoders. Programmable logic devices (CSE370, CSE467) Computational hardware Digital logic (CSE370) Gates and flip-flops: glue logic, simple FSMs, registers Two-level PLDs: FSMs, muxes, decoders Programmable logic devices (CSE370, CSE467) Field-programmable

More information

Buses and Parallel Input/Output

Buses and Parallel Input/Output Buses and Parallel Input/Output Lecturer: Sri Parameswaran Notes by: Annie Guo Week7 1 Lecture Overview Buses Computer buses I/O Addressing Memory mapped I/O Separate I/O Parallel input/output AVR examples

More information

Logic Instructions and Programs READING

Logic Instructions and Programs READING 1 P a g e Logic Instructions and Programs READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 5: Arithmetic, Logic

More information

Microcontroller Intel [Instruction Set]

Microcontroller Intel [Instruction Set] Microcontroller Intel 8051 [Instruction Set] Structure of Assembly Language [ label: ] mnemonic [operands] [ ;comment ] Example: MOV R1, #25H ; load data 25H into R1 2 8051 Assembly Language Registers

More information

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER OBJECT: EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER To understand the structure and operating instruction of the microprocessor trainer. INTRODUCTION: The MKT 8085 is a single-board microcomputer,

More information

Microcomputer Architecture and Programming

Microcomputer Architecture and Programming IUST-EE (Chapter 1) Microcomputer Architecture and Programming 1 Outline Basic Blocks of Microcomputer Typical Microcomputer Architecture The Single-Chip Microprocessor Microprocessor vs. Microcontroller

More information

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING CHAPTER 2 8051 ASSEMBLY LANGUAGE PROGRAMMING Registers Register are used to store information temporarily: A byte of data to be processed An address pointing to the data to be fetched The vast majority

More information

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261/V ATtiny461/V ATtiny861/V. Preliminary

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261/V ATtiny461/V ATtiny861/V. Preliminary Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 123 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

ET2640 Microprocessors

ET2640 Microprocessors ET2640 Microprocessors Unit -2 Processor Programming Concepts Basic Control Instructor : Stan Kong Email : skong@itt-tech.edu Figure 2 4 Bits of the PSW Register 8051 REGISTER BANKS AND STACK 80 BYTES

More information

University of Florida EEL 4744 Dr. Eric M. Schwartz. Page 1/11 Revision 0 20-Feb-14 Mixed C and Assembly (for Atmel XMEGA)

University of Florida EEL 4744 Dr. Eric M. Schwartz. Page 1/11 Revision 0 20-Feb-14 Mixed C and Assembly (for Atmel XMEGA) Page 1/11 Revision 0 20-Feb-14 KEY WORDS Compiler, Inline Assembly, GNU Assembler, GCC, AVR-GCC RESOURCES GNU Assembler Resource - http://sourceware.org/binutils/docs-2.23.1/as/index.html AVR-LibC Inline

More information

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller of 8085 microprocessor 8085 is pronounced as "eighty-eighty-five" microprocessor. It is an 8-bit microprocessor designed by Intel in 1977 using NMOS technology. It has the following configuration 8-bit

More information

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD Mechatronics and Microcomputers Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD ATmega128 CPU Single-level pipelining Egyciklusú ALU működés Reg. reg., reg. konst. közötti műveletek

More information

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261 ATtiny461 ATtiny861. Automotive

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261 ATtiny461 ATtiny861. Automotive Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 123 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

COMP3221: Microprocessors and Embedded Systems

COMP3221: Microprocessors and Embedded Systems Embedded Systems Lecture 6: Addressing Modes http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2005 Addressing Modes Overview Instruction Examples 1 2 Operands Immediate Addressing Instructions

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22 ATtiny22L. Preliminary. Features. Description

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22 ATtiny22L. Preliminary. Features. Description Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

Exam I Review February 2017

Exam I Review February 2017 Exam I Review February 2017 Binary Number Representations Conversion of binary to hexadecimal and decimal. Convert binary number 1000 1101 to hexadecimal: Make groups of 4 bits to convert to hexadecimal,

More information

COMP2121: Microprocessors and Interfacing. Instruction Formats and Addressing Modes

COMP2121: Microprocessors and Interfacing. Instruction Formats and Addressing Modes COMP2121: Microprocessors and Interfacing Instruction Formats and Addressing Modes http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Instruction format AVR instruction format

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features Features High-performance, Low-power AVR 8-bit Microcontroller RISC Architecture 130 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation

More information

8-bit Instruction Set

8-bit Instruction Set Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two s complement overflow indicator S: N V, For signed tests H: Half Carry Flag

More information

APPENDIX D FLOWCHARTS AND PSEUDOCODE OVERVIEW

APPENDIX D FLOWCHARTS AND PSEUDOCODE OVERVIEW APPENDIX D FLOWCHARTS AND PSEUDOCODE OVERVIEW This appendix provides an introduction to writing flowcharts and pseudocode. 689 Flowcharts If you have taken any previous programming courses, you are probably

More information

AVR Assembler Examples

AVR Assembler Examples AVR Assembler Examples AVR specific examples Credit to Dr. Robucci for slide information SBR Set bits in reg Equivalent to an ORI REQUIRES MASKS, not bit number m169pdef.inc Include file detailing register

More information

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features.

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features. Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss Grundlagen Microcontroller Processor Core Günther Gridling Bettina Weiss 1 Processor Core Architecture Instruction Set Lecture Overview 2 Processor Core Architecture Computes things > ALU (Arithmetic Logic

More information

Chapter 1 Microprocessor architecture ECE 3120 Dr. Mohamed Mahmoud http://iweb.tntech.edu/mmahmoud/ mmahmoud@tntech.edu Outline 1.1 Computer hardware organization 1.1.1 Number System 1.1.2 Computer hardware

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

AVR Control Transfer -AVR Branching

AVR Control Transfer -AVR Branching 1 P a g e AVR Control Transfer -AVR Branching Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 3: Branch, Call,

More information

CMPE C Programming & Embedded Systems. Discussion I (Version 2.0) August 31, 2014

CMPE C Programming & Embedded Systems. Discussion I (Version 2.0) August 31, 2014 CMPE 311 - C Programming & Embedded Systems Discussion I (Version 2.0) August 31, 2014 Version History Version 2.1 - (August 31, 2015) - Addition Pin Connections Section and Document Verification. Version

More information

AVR. (AVR Assembly Language) Assembler . ก ก

AVR. (AVR Assembly Language) Assembler . ก ก AVR (AVR Assembly Language). ก ก Assembler 2 1 ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load

More information

APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW

APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW In this appendix, we describe each intruction of the ATmega328. In many cases, a simple code example is given to clarify the instruction. Instructions are

More information

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP 805 SFR Bus Digital Blocks Semiconductor IP 805 Microcontroller Configurable Peripherals General Description The Digital Blocks (Configurable Peripherals) Microcontroller Verilog IP Core is complaint with

More information

Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices

Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices Kostas Papagiannopoulos Aram Verstegen July 11, 2013 Papagiannopoulos and Verstegen July 11, 2013 Speed and Size-Optimized

More information

8-bit Instruction Set

8-bit Instruction Set Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two s complement overflow indicator S: N V, For signed tests H: Half Carry Flag

More information

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Lecture 11 Interrupts Interrupts Slide 1 Interrupts One way to think of interrupts is that they are hardwaregenerated functions calls Internal Hardware When timer rolls over,

More information

Processor design - MIPS

Processor design - MIPS EASY Processor design - MIPS Q.1 What happens when a register is loaded? 1. The bits of the register are set to all ones. 2. The bit pattern in the register is copied to a location in memory. 3. A bit

More information

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language)

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language) 3 AVR (AVR Assembly Language). ก ก ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load register

More information

Example of A Microprogrammed Computer

Example of A Microprogrammed Computer Example of A Microprogrammed omputer The purpose of this example is to demonstrate some of the concepts of microprogramming. We are going to create a simple 16-bit computer that uses three buses A, B,

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT90S8515

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT90S8515 Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up

More information

9/25/ Software & Hardware Architecture

9/25/ Software & Hardware Architecture 8086 Software & Hardware Architecture 1 INTRODUCTION It is a multipurpose programmable clock drive register based integrated electronic device, that reads binary instructions from a storage device called

More information

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA) COMP2121: Microprocessors and Interfacing Instruction Set Architecture (ISA) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Contents Memory models Registers Data types Instructions

More information

8-bit Microcontroller with 4K/8K bytes In-System Programmable Flash AT90S4414 AT90S8515. Features. Pin Configurations

8-bit Microcontroller with 4K/8K bytes In-System Programmable Flash AT90S4414 AT90S8515. Features. Pin Configurations Features Utilizes the AVR RISC Architecture AVR - High-performance and Low-power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers

More information

8051 Microcontroller Assembly Programming

8051 Microcontroller Assembly Programming 8051 Microcontroller Assembly Programming EE4380 Fall 2002 Class 3 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Topics Machine code 8051 Addressing Modes

More information

ECED3204: Microprocessor Part I--Introduction

ECED3204: Microprocessor Part I--Introduction ECED3204: Microprocessor Part I--Introduction Jason J. Gu Department of 1 Outline i. Computer ii. Processor iii. Embedded System iv. Memory v. Program Execution VI. VII. VIII. IX. AVR AVR Memory AVR CPU

More information

AVR Instruction Set Encoding

AVR Instruction Set Encoding 1 P age AVR Instruction Set Encoding READING 1. "AVR Instruction Set" document doc856 "The Program and Data Addressing Modes." 2. In this lecture I will teach you how to translate your assembly code into

More information

VCC PB2 (SCK/ADC1/T0/PCINT2) PB1 (MISO/AIN1/OC0B/INT0/PCINT1) PB0 (MOSI/AIN0/OC0A/PCINT0)

VCC PB2 (SCK/ADC1/T0/PCINT2) PB1 (MISO/AIN1/OC0B/INT0/PCINT1) PB0 (MOSI/AIN0/OC0A/PCINT0) Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 120 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

AE66/AC66/AT66/ AE108/AC108/AT108 MICROPROCESSORS & MICROCONTROLLERS

AE66/AC66/AT66/ AE108/AC108/AT108 MICROPROCESSORS & MICROCONTROLLERS Q.2 a. Draw pin diagram and signal group diagram of 8085 microprocessor. (8) b. List out the various categories of the 8085 instructions. Give examples of the instructions for each group. (8) Data transfer

More information

ENE 334 Microprocessors

ENE 334 Microprocessors Page 1 ENE 334 Microprocessors Lecture 9: MCS-51: Moving Data : Dejwoot KHAWPARISUTH http://webstaff.kmutt.ac.th/~dejwoot.kha/ ENE 334 MCS-51 Moving Data Page 2 Moving Data: Objectives Use commands that

More information

8-Bit Microcontroller with 1K bytes In-System Programmable Flash AT90S1200. Features. Description. Pin Configuration

8-Bit Microcontroller with 1K bytes In-System Programmable Flash AT90S1200. Features. Description. Pin Configuration Features AVR - High Performance and Low Power RISC Architecture 89 Powerful Instructions - Most Single Clock Cycle Execution 1K bytes of In-System Reprogrammable Flash SPI Serial Interface for Program

More information

Subject Code: Model Answer Page No: /25

Subject Code: Model Answer Page No: /25 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

8-bit Microcontroller with 4/8K Bytes In-System Programmable Flash. ATtiny48/88. Preliminary

8-bit Microcontroller with 4/8K Bytes In-System Programmable Flash. ATtiny48/88. Preliminary Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 23 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

Register-Level Programming

Register-Level Programming Introduction Register-Level Programming Programming can be considered a set a instructions that are executed in a precise order. A programming simulator can evaluate how instructions store, move and calculate

More information

A First Look at Microprocessors

A First Look at Microprocessors A First Look at Microprocessors using the The General Prototype Computer (GPC) model Part 2 Can you identify an opcode to: Decrement the contents of R1, and store the result in R5? Invert the contents

More information

CPE 323 MSP430 INSTRUCTION SET ARCHITECTURE (ISA)

CPE 323 MSP430 INSTRUCTION SET ARCHITECTURE (ISA) CPE 323 MSP430 INSTRUCTION SET ARCHITECTURE (ISA) Aleksandar Milenković Email: milenka@uah.edu Web: http://www.ece.uah.edu/~milenka Objective Introduce MSP430 Instruction Set Architecture (Class of ISA,

More information

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ). AS12 Assembler Directives A Summary of 9S12 instructions Disassembly of 9S12 op codes Huang Section 1.8, Chapter 2 MC9S12 V1.5 Core User Guide Version 1.2, Section 12 o A labels is a name assigned the

More information

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP Digital Blocks Semiconductor IP 805 Microcontroller General Description The Digital Blocks Microcontroller Verilog IP Core is complaint with the MCS 5 Instruction Set and contains standard 805 MCU peripherals,

More information

Computer System Architecture

Computer System Architecture CSC 203 1.5 Computer System Architecture Department of Statistics and Computer Science University of Sri Jayewardenepura Addressing 2 Addressing Subject of specifying where the operands (addresses) are

More information