COMP2121: Microprocessors and Interfacing

Slides:



Advertisements
Similar presentations
AVR ATMega32 Elementary Input / Output
Advertisements

EXTERNAL COMMUNICATIONS DESIGNING AN EXTERNAL 3 BYTE INTERFACE Mark Neil - Microprocessor Course 1 External Memory & I/O.
COMP3221: Microprocessors and Embedded Systems Lecture 17: Computer Buses and Parallel Input/Output (I) Lecturer: Hui.
Robotics Club, Snt Council2 The 3 Schools of Robotics: Mechanical Design – Types of motors – Material selection –
MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable.
Programming Microcontrollers B. Furman 19MAR2011.
Introduction of Holtek HT-46 series MCU
Programming the ATmega16
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
Input/Output mechanisms
I/O Ports CS-280 Dr. Mark L. Hornick 1. CS-280 Dr. Mark L. Hornick 2 Ports are channels from the CPU to external hardware and software Atmega32 has: 4.
MICROPROCESSOR INPUT/OUTPUT
Basic I/O Interface A Course in Microprocessor
By, Prof. Tambe S. S. S.N.D. College of Engineering and Research Center Department of Electrical Engineering.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Programmable Peripheral Interface Parallel port Interface 8255
Module 11 Adapted By and Prepared James Tan © 2001.
PPI-8255.
DsPIC30F4011 Fall DIP Switches  The upper four switches of SW1 are used to enable LEDs connected to PORTB/C, PORTA/D, PORTE and PORTF. For example,
Chapter Microcontroller
Introduction to AVR Name : 1) Abhishek Yadav ) Prakash Giri ) Kheni Niral ) Bhadresh Langadiya Branch.
INTERFACING HARDWARE WITH MICROCONTROLLER GUIDED BY: Prof. ASIF SIR 1. AKSHAY KIRAN 2. DEEP PARIKH 3. JIGAR PATEL 4. TILAK PATEL ,05,D2D06,09.
Application Case Study Christmas Lights Controller
AVR I/O Port Programming
I/O SYSTEMS MANAGEMENT Krishna Kumar Ahirwar ( )
The 8085 Microprocessor Architecture
Environment Temperature Monitor
Input/Output Ports and Interfacing
For further information
9S12C Multiplexed Bus Expansion
CPU Sequencing 6/30/2018.
General Purpose I/O.
Memory Systems 7/21/2018.
The 8085 Microprocessor Architecture
AVR Addressing Modes Subject: Microcontoller & Interfacing
Introduction of microprocessor
The 8255 Programmable Peripheral Interface
Basics of digital systems
Dr. Michael Nasief Lecture 2
COMP2121: Microprocessors and Interfacing
E3165 DIGITAL ELECTRONIC SYSTEM
CS703 - Advanced Operating Systems
The Arduino Microcontroller: Atmel AVR Atmega 328
COMP2121: Microprocessors and Interfacing
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Introduction to Microprocessors and Microcontrollers
Interfacing Memory Interfacing.
8255.
Elec 2607 Digital Switching Circuits
COMP2121: Microprocessors and Interfacing
Serial Communication Interface: Using 8251
I/O Ports in AVR Sepehr Naimi
Parallel communication interface 8255
Tim Sumner, Imperial College, Rm: 1009, x47552
Programmable Peripheral Interface
82C55 Programmable Peripheral Interface
I/O Ports in AVR Sepehr Naimi
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
The 8085 Microprocessor Architecture
8051 Micro Controller.
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
COMP3221: Microprocessors and Embedded Systems
Costas Foudas, Imperial College, Rm: 508, x47590
CPU Sequencing 7/20/2019.
Advanced Computer Architecture Lecture 3
Presentation transcript:

COMP2121: Microprocessors and Interfacing I/O Devices (I) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017

Overview I/O Ports AVR Ports

What is I/O? I/O is Input or Output (Input/Output). It can be: A number of digital bits formed into a number of digital inputs or outputs called a port. These are usually eight bits wide and thus referred to as a BYTE wide port, ie., byte wide input port, byte wide output port. A digital I/O port can be implemented by a number of D type flip-flops. A serial line from the microprocessor (Transmit or TX) and a serial line to the microprocessor (Receive or RX) allowing serial data in the form of a bit stream to be transmitted or received via a two wire interface. Other I/O devices such as Analogue-to-Digital Converters (ADC) and Digital-to-Analogue Converters (DAC), Timer modules, Interrupt controllers etc.

Internal Structure of an Input Port The following diagram shows the structure of 4-bit input port. The input port allows outside world inputs to be stored in the data latches so they can be read by the microprocessor via the data bus.

Tri-state Gates The data bus connections must be via tri-state buffers so that the input port is only connected to the data bus when the input port is selected. This is achieved by connecting a chip select signal to the enable input signal line. Note that the tri-state enable is active low. 1G A Y 0 0 0 A Y 0 1 1 1 0 X 1G High Impedance 1 1 X Tri-state gate

Internal Structure of an Output Port An output port can be implemented by a number of D type flip-flops. The following diagram shows a 4-bit output port. The inputs are connected to data bus and the outputs are connected to any output interface.

Pin Layout of AVR ATMega2560

The functional description of one port pin AVR Ports (1/4) The functional description of one port pin

AVR Ports (2/4) All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports. The direction of one port pin can be changed without unintentionally changing the direction of any other pin with the SBI and CBI instructions. The pin driver is strong enough to drive LED displays directly. Three I/O memory address locations are allocated for each port, one each for the Data Register – PORTx, Data Direction Register – DDRx, and the Port Input Pins – PINx. x is one of A, B, C, D, E, F, G, H, I, J, K and L. The Port Input Pins I/O location is read only, while the Data Register and the Data Direction Register are read/write.

AVR Ports (3/4) Each port pin consists of three register bits: DDxn, PORTxn, and PINxn. The DDxn bits are accessed at the DDRx I/O address, the PORTxn bits at the PORTx I/O address, and the PINxn bits at the PINx I/O address. The DDxn bit in the DDRx Register selects the direction of this pin. If DDxn is written logic one, Pxn is configured as an output pin. If DDxn is written logic zero, Pxn is configured as an input pin. If PORTxn is written logic one when the pin is configured as an output pin, the port pin is driven high (one). If PORTxn is written logic zero when the pin is configured as an output pin, the port pin is driven low (zero).

AVR Ports (4/4) Port Pin Configurations PUD ( Pull-UP Disable) is a bit in MCUCR register (MCU Control Register). When this bit is written to one, the pull-ups in the I/O ports are disabled even if the DDxn and PORTxn Registers are configured to enable the pull-ups ({DDxn, PORTxn} = 0b01).

Reading An Externally Applied Pin Value (1/3) Synchronization when Reading an Externally Applied Pin Value

Reading An Externally Applied Pin Value (2/3) Independent of the setting of Data Direction bit DDxn, the port pin can be read through the PINxn Register bit. The PINxn Register bit and the preceding latch constitute a synchronizer. This is needed to avoid metastability if the physical pin changes value near the edge of the internal clock, but it also introduces a delay. The maximum and minimum propagation delays are denoted by tpd,max and tpd,min respectively.

Reading An Externally Applied Pin Value (3/3) Consider the clock period starting shortly after the first falling edge of the system clock. The latch is closed when the clock is low, and goes transparent when the clock is high, as indicated by the shaded region of the “SYNC LATCH” signal. The signal value is latched when the system clock goes low. It is clocked into the PINxn Register at the succeeding positive clock edge. As indicated by the two arrows tpd,max and tpd,min, a single signal transition on the pin will be delayed between ½ and 1½ system clock period depending upon the time of assertion.

Reading A Software Assigned Pin Value (1/2) Synchronization when Reading a Software Assigned Pin Value

Reading A Software Assigned Pin Value (2/2) When reading back a software assigned pin value, a nop instruction must be inserted. The out instruction sets the “SYNC LATCH” signal at the positive edge of the clock. In this case, the delay tpd through the synchronizer is one system clock period.

Example 1: Reading a Pin Value (1/2) ; Define pull-ups and set outputs high ; Define directions for port pins ldi r16,(1<<PB7)|(1<<PB6)|(1<<PB1)|(1<<PB0) ldi r17,(1<<DDB3)|(1<<DDB2)|(1<<DDB1)|(1<<DDB0) out PORTB,r16 out DDRB,r17 ; Insert nop for synchronization nop ; Read port pins in r16,PINB ...

Example 1: Reading a Pin Value (2/2) Example 1 shows how to set Port B pins 0 and 1 high, 2 and 3 low, and define the port pins from 4 to 7 as input with pull-ups assigned to port pins 6 and 7. The resulting pin values are read back again, a nop instruction is included to be able to read back the value recently assigned to some of the pins.

Example 2: Controlling LEDs (1/3) Consider our AVR development board. Assume that Push Button PB0 is connected to PA0 (PINA0), and Eight LEDs (LED 0 to LED 7) are connected to PC0 (PINC0) to PC7 (PINC7), respectively. Whenever PB0 is pushed, the following program turns the LEDs on if they are off; otherwise, it turns the LEDs off. .include "m2560def.inc" .def temp =r16 .def count=r25 .equ PATTERN1 = 0x00 .equ PATTERN2 = 0xFF .cseg ;Notice that the following instruction is stored at 0x0 clr count ; Set count to 0 ser temp ; Set temp to 0b11111111

Example 2: Controlling LEDs (2/3) out PORTC, temp ; Write ones to all the LEDs out DDRC, temp ; PORTC is all outputs out PORTA, temp ; Enable pull-up resistors on PORTA clr temp out DDRA, temp ; PORTA is all inputs loop: sbic PINA, 0 ; Skip the next instruction if PB0 is pushed rjmp loop ; If not pushed, check PB0 again cpi count, 0 breq ledon

Example 2: Controlling LEDs (3/3) ldi temp, PATTERN1 ; Turn the LEDs off if they are on out PORTC, temp clr count rjmp loop ledon: ldi temp, PATTERN2 ; Turn the LEDs on if they are off. inc count

ATmega2560 Block Diagram

AVR Board (1/2)

AVR Board (2/2) ATmega2560 microcontroller Motor LEDs LCD 4*4 keypad Speaker Microphone Push buttons Reset button

Reading Material Overview, AVR CPU Core, I/O Port in ATmega2560 Data Sheet. Introduction to Pull-Up Resistors. http://www.seattlerobotics.org/encoder/mar97/basics.html http://en.wikipedia.org/wiki/Three-state_logic.