Introduction. Embedded system functionality aspects. Processing. Storage. Communication. Transformation of data Implemented using processors

Similar documents
Interface: Ports. Microprocessor System Design EHB432E Lecture - 6. Interface: Bus. Timing Diagrams. Istanbul Technical University

Interfacing. Introduction. Introduction Addressing Interrupt DMA Arbitration Advanced communication architectures. Vahid, Givargis

Flow Charts and Assembler Programs

Input/Output Ports and Interfacing

Interfacing. Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

Interface Synthesis. Communication Synthesis

Embedded System Design

Embedded Systems Design: A Unified Hardware/Software Introduction. Chapter 6 Interfacing

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

6.1 Introduction. 6.2 Timing diagrams 6-1. Chapter 6: Interfacing

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

The University of Texas at Arlington Lecture 5

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Introduction to Embedded System I/O Architectures

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

Micro II and Embedded Systems

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

Binary Outputs and Timing

Laboratory Exercise 5 - Analog to Digital Conversion

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

C and Embedded Systems. So Why Learn Assembly Language? C Compilation. PICC Lite C Compiler. PICC Lite C Optimization Results (Lab #13)

EXPERIMENT 4: Parallel Input/Output. Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

PIC Discussion. By Eng. Tamar Jomaa

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

ME 515 Mechatronics. A microprocessor

CENG-336 Introduction to Embedded Systems Development. Timers

EEE111A/B Microprocessors

LPTCOM. Bruce Misner Lakehead University h d3 RD2 pin 21. RD3 pin h d4. RD4 pin 27 RD5 pin h d5. RD6 pin 29 RD7 pin H d6

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

ECE Homework #3

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Target Board PIC877-TB - Reference Manual

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

SLAM: Simultaneous Localization and Mapping of small sized ground robotic vehicles

Basic I/O Interface

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

Chapter 9. Input/Output (I/O) Ports and Interfacing. Updated: 3/13/12

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

Physics 335 Intro to MicroControllers and the PIC Microcontroller

Lecture (04) PIC16F84A (3)

Summer 2003 Lecture 21 07/15/03

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

ME 6405 Introduction to Mechatronics

PIC 16F84A programming (II)

I/O Design. Input / Output Instructions. Engineering 4862 Microprocessors. Lecture 23. Cheng Li

Embedded Systems Programming and Architectures

Learning Objectives:

ME 475 Lab2 Introduction of PIC and Programming. Instructor: Zhen Wang

Embedded system functionality aspects

Chapter NINE 8088,80286 MICROPROCESSORS AND ISA BUS

Module 3. Embedded Systems I/O. Version 2 EE IIT, Kharagpur 1

Section 4. Architecture

Microcontroller basics

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

ECE 354 Computer Systems Lab II. Memory and Indirect Addressing

Lecture (02) PIC16F84 (I)

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

DERTS Design Requirements (1): Microcontroller Architecture & Programming

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

Midrange 8b PIC Microcontrollers. ECE Senior Design 14 February 2017

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

History and Basic Processor Architecture

ENGG3380: Computer Organization and Design Lab4: Buses and Peripheral Devices

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

INTERFACING INTERFACING. Richa Upadhyay Prabhu. NMIMS s MPSTME February 25, 2016

PIC16F /40-Pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

Figure 1: Pushbutton without Pull-up.

EE 308 Spring Lecture 28 March 30, 2012 Review for Exam 2. Introduction to the MC9S12 Expanded Mode

Lecture 25 March 23, 2012 Introduction to Serial Communications

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

Using MSI Logic To Build An Output Port

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

ECE 372 Microcontroller Design

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

MICROPROCESSOR AND MICROCONTROLLER BASED SYSTEMS

Section 16. Basic Sychronous Serial Port (BSSP)

Week1. EEE305 Microcontroller Key Points

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

EEM336 Microprocessors I. I/O Interface

EC2304-MICROPROCESSOR AND MICROCONROLLERS 2 marks questions and answers UNIT-I

Microcontroller Overview

Section 30. In-Circuit Serial Programming (ICSP )

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

CONNECT TO THE PIC. A Simple Development Board

82C55. Programmable Peripheral Interface. Interfacing Part III

I/O Ports with Interrupt-on-Change (IOC)

ECE 354 Introduction to Lab 2. February 23 rd, 2003

ﻢﯿﺣﺮﻟا ﻦﻤﺣﺮﻟا ﷲا ﻢﺴﺑ

INPUT-OUTPUT ORGANIZATION

Chapter TEN. Memory and Memory Interfacing

Transcription:

Input/Output 1

Introduction Embedded system functionality aspects Processing Transformation of data Implemented using processors Storage Retention of data Implemented using memory Communication Transfer of data between processors and memories Implemented using buses Called interfacing 2

A simple bus Wires: Uni-directional or bi-directional One line may represent multiple wires Bus Set of wires with a single function Address bus, data bus Processor rd'/wr enable addr[0-11] data[0-7] Memory Or, entire collection of wires Address, data and control Associated protocol: rules for communication bus bus structure 3

Ports port Processor rd'/wr enable Memory addr[0-11] data[0-7] Conducting device on periphery Connects bus to processor or memory Often referred to as a pin Actual pins on periphery of IC package that plug into socket on printed-circuit board Sometimes metallic balls instead of pins Today, metal pads connecting processors and memories within single IC Single wire or set of wires with single function E.g., 12-wire address port bus 4

Timing Diagrams Most common method for describing a communication protocol Time proceeds to the right on x-axis Control signal: low or high May be active low (e.g., go, /go, or go_l) Use terms assert (active) and deassert Asserting go means go=0 Data signal: not valid or valid Protocol may have subprotocols Called bus cycle, e.g., read and write Each may be several clock cycles Read example rd /wr set low,address placed on addr for at least t setup time before enable asserted, enable triggers memory to place data on data wires by time t read rd'/wr enable addr data rd'/wr enable addr data t setup t read read protocol t setup t write write protocol 5

Basic protocol concepts Actor: master initiates, servant (slave) respond Direction: sender, receiver Addresses: special kind of data Specifies a location in memory, a peripheral, or a register within a peripheral Time multiplexing Share a single set of wires for multiple pieces of data Saves wires at expense of time Master data(15:0) req Time-multiplexed data transfer Servant data(15:0) Master addr data req Servant addr data mux data(8) demux mux addr/data demux req req data 15:8 7:0 addr/data addr data data serializing address/data muxing 6

Basic protocol concepts: control methods Master req Servant Master req Servant ack data data req data 1 2 3 4 req ack data 1 2 3 4 t access 1. Master asserts req to receive data 2. Servant puts data on bus within time t access 3. Master receives data and deasserts req 4. Servant ready for next request 1. Master asserts req to receive data 2. Servant puts data on bus and asserts ack 3. Master receives data and deasserts req 4. Servant ready for next request Strobe protocol Handshake protocol 7

A strobe/handshake compromise Master req wait data Servant req 1 3 req 1 4 wait wait 2 3 data 2 4 data 5 t access 1. Master asserts req to receive data 2. Servant puts data on bus within time t access (wait line is unused) 3. Master receives data and deasserts req 4. Servant ready for next request t access 1. Master asserts req to receive data 2. Servant can't put data within t access, asserts wait ack 3. Servant puts data on bus and deasserts wait 4. Master receives data and deasserts req 5. Servant ready for next request Fast-response case Slow-response case 8

ISA bus protocol memory access ISA: Industry Standard Architecture Common in 80x86 s Features 20-bit address Compromise strobe/handshake control 4 cycles default Unless CHRDY deasserted resulting in additional wait cycles (up to 6) Microprocessor Memory I/O Device CYCLE CLOCK D[7-0] A[19-0] ALE /MEMR CHRDY CYCLE CLOCK D[7-0] A[19-0] ISA bus memory-read bus cycle C1 C2 WAIT C3 C4 ADDRESS memory-write bus cycle C1 C2 WAIT C3 C4 ADDRESS DATA DATA ALE /MEMW CHRDY 9

Microprocessor interfacing: I/O addressing A microprocessor communicates with other devices using some of its pins Port-based I/O (parallel I/O) Processor has one or more N-bit ports Processor s software reads and writes a port just like a register E.g., P0 = 0xFF; v = P1.2; -- P0 and P1 are 8-bit ports Bus-based I/O Processor has address, data and control ports that form a single bus Communication protocol is built into the processor A single instruction carries out the read or write protocol on the bus 10

Compromises/extensions Parallel I/O peripheral When processor only supports bus-based I/O but parallel I/O needed Each port on peripheral connected to a register within peripheral that is read/written by the processor Extended parallel I/O When processor supports port-based I/O but more ports needed One or more processor ports interface with parallel I/O peripheral extending total number of ports available for I/O e.g., extending 4 ports to 6 ports in figure Processor Memory Parallel I/O peripheral Port A System bus Port B Port C Adding parallel I/O to a busbased I/O processor Processor Port 0 Port 1 Port 2 Port 3 Parallel I/O peripheral Port A Port B Port C Extended parallel I/O 11

Types of bus-based I/O: memory-mapped I/O and standard I/O Processor talks to both memory and peripherals using same bus two ways to talk to peripherals Memory-mapped I/O Peripheral registers occupy addresses in same address space as memory e.g., Bus has 16-bit address lower 32K addresses may correspond to memory upper 32k addresses may correspond to peripherals Standard I/O (I/O-mapped I/O) Additional pin (M/IO) on bus indicates whether a memory or peripheral access e.g., Bus has 16-bit address all 64K addresses correspond to memory when M/IO set to 0 all 64K addresses correspond to peripherals when M/IO set to 1 12

Memory-mapped I/O vs. Standard I/O Memory-mapped I/O Requires no special instructions Assembly instructions involving memory like MOV and ADD work with peripherals as well Standard I/O requires special instructions (e.g., IN, OUT) to move data between peripheral registers and memory Standard I/O No loss of memory addresses to peripherals Simpler address decoding logic in peripherals possible When number of peripherals much smaller than address space then high-order address bits can be ignored smaller and/or faster comparators 13

I/O on 16F877 14

Ports represent physical connection of Central Processing Unit with an outside world. Microcontroller uses them in order to monitor or control other components or devices. 15

All input and output on the PIC is performed via the I/O ports. I/O ports are like RAM locations with wires leading from the bits to the pins of the microchip. 16

PORTA is a 6-bit wide, bi-directional port. PORTB, PORTC, and PORTD are an 8-bit wide, bidirectional ports. PORTE is a 3-bit wide, bi-directional port. 17

18

19

I/O ports on a PIC are memory mapped. This means that to read from or write to a port on a PIC the program must read from or write to a special RAM location. To access PORTA on the 16F877 the program must access the RAM at address location 5. 20

The I/O ports on the PIC can be used as either inputs or outputs. Configuring a port for input or output is done by setting or clearing the data direction register for the port. On the PIC each bit of each port has a data direction bit. Therefore it is possible to set some bits within a port as inputs and others within the same port as outputs. For most ports, the I/O pin s direction (input or output) is controlled by the data direction register, called the TRIS register. TRIS<x> controls the direction of PORT<x>. A 1 in the TRIS bit corresponds to that pin being an input, while a 0 corresponds to that pin being an output. An easy way to remember is that a 1 looks like an I (input) and a 0 looks like an O (output). Note that these registers are all in bank 1 21

PORTA 0 0 0 0 0 0 0 0 TRISA 0 0 1 0 0 1 0 1 DIRECTION OUT OUT IN OUT OUT IN OUT IN To access TRISA on the 16F877 the program must access the RAM at address location 133 (this is actually 5 + 128). 22

23

PORTA is a little different. Since PORTA can be analog or digital, you also need to tell the PIC that PORTA is digital. This is done by writing 0x06 to ADCON1 24

L0: Bank0: Bank1: call Bank1 clrf 0x85 ; TRISA = 0 clrf 0x86 ; TRISB = 0 clrf 0x87 ; TRISC = 0 movlw 6 movwf 0x9F ; ADCON1 = 6 call Bank0 clrf 7 ; PORTC = 0 clrf 6 ; PORTB = 0 clrf 5 ; PORTA = 0 goto L0 ; stop (infinite loop) bcf 3,5 ; bcf STATUS, RP0 bcf 3,6 ; bcf STATUS, RP1 return bsf 3,5 ; bsf STATUS, RP0 bcf 3,6 ; bcf STATUS, RP0 return 25

bsf STATUS, RP0 ;Bank1 movlw 0x0F ;Defining input and output pins movwf TRISB ;Writing to TRISB register bcf STATUS, RP0 ;Bank0 bsf PORTB, 4 ;PORTB <7:4>=0 bsf PORTB, 5 bsf PORTB, 6 bsf PORTB, 7 The above example shows how pins 0, 1, 2, and 3 are designated input, and pins 4, 5, 6, and 7 for output, after which PORTB output pins are set to one. 26

initialize_portc: clrf PORTC ; clear the data register to cause ; outputs to be 0 bsf STATUS,RP0 ; switch to bank 1 movlw 0xBF ; each bit with a 1 is input, ; otherwise output Bit 6 output movwf TRISC ; setup the port bcf STATUS,RP0 ; switch back to bank 0 return ; exit 27

The RA4 pin is a Schmitt Trigger input and an open drain output. All other RA port pins have TTL input levels and full CMOS output drivers. 28

To add flexibility and functionality to a device, some pins are multiplexed with an alternate function(s). These functions depend on which peripheral features are on the device. In general, when a peripheral is functioning, that pin may not be used as a general purpose I/O pin. 29

PORTA is a 6-bit I/O port (shared with A/D converter) The operation of each pin is selected by clearing/setting the control bits in the ADCON1 register (A/D Control Register1). Pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. 30

PORTD can be configured as an 8-bit wide microprocessor port (parallel slave port) by setting control bit PSPMODE (TRISE<4>). In this mode, the input buffers are TTL. 8-bit Parallel Slave Port - function allow another processor to read from a data buffer in the PIC. In Slave mode, it is asynchronously readable and writable by the external world through RD control input pin RE0/RD and WR control input pin RE1/WR. 31

Summary 32