350 likes | 460 Views
Microprocessor-based Systems. Course 10 Design of Input/Output interfaces (continuation). USB – Universal Serial Bus. Goal: a communication standard for a wide range of peripheral devices, connectable to a PC Mouse, keyboard, joy-stick – input devices Printer – output device
E N D
Microprocessor-based Systems Course 10 Design of Input/Output interfaces (continuation)
USB – Universal Serial Bus • Goal: • a communication standard for a wide range of peripheral devices, connectable to a PC • Mouse, keyboard, joy-stick – input devices • Printer – output device • Scanner, Digital camera, Webcam – multimedia devices • Memory-stick – storage devices • replaces traditional serial and parallel interfaces • Solution: • multilayer protocol with master-slave functionality
Performance features • Very high speed • Wide bandwidth (12 Mbs) • PnP (Plag and Play) facilities • One interface handle many devices in the same time • Many communication channels on the same physical support • Transmission modes adapted to different dataflow types: • sporadic data • periodic data • high volume of data
Physical characteristics • Transmission on standard cable: • 4 wires: • 2 for power supply: Vcc (red), GND (brown) => 5V, 500mA • 2 for data (blue and yellow ), twisted • Cable length: • maximum 5 m • extensible with HUBs until 30 m • Standard connectors: • type “A” – for the computer (host or master) • type “B” – for devices • Connectable during normal work (hot-swappable)
Host (computer) Root Hub Device Device Device Device Device Device Device Compound Device Hub Hub Star topology Physical topology of the USB (network)
Device types: • “Host” (master) – usually a computer • the device that controls the communication on the USB network • distributes network access rights to the other devices • moditors the USB network topology • “Device” – peripheral device connected to the computer • offers a given “functionality” for the host (ex: mouse, printer, scanner, etc.) • when it is connected the device gets a unique address from the host • the format of data depends on the type of the device • information exchanged between the host and the device may be: • general information • information specific for a given type of devices
Device types (cont.): • “Hub” – amplifying and branching device • “Compound Device” – • contains a HUB and some devices • every device has its own address (including the HUB) • “Composite Device” – • contains a number of functionalities but under a single address
The USB protocol model • the protocol is organized on three hierarchical layers: • USB bus interface layer – the physical layer • handles the physical transmission of data (on the cable) • USB device layer – • assures the logical connection between the host and the devices • it is the operating system’s vision over the USB interface • Function layer – • assures the connection between the “client software” in the host and the “function” in the device
The USB protocol model Host Device Client software Function System software Logical device Bus interface USB controller Physical connection Logical connection
Logical Device Logical Device Logical Device Logical Device Logical topology (layer 2) Host • Direct connections between the host and the logical devices • the physical connections (including HUBs) are ignored
Client software Client software Client software Client software Function Function Function Function Application level topology (layer 3) Host Dispozitiv
Communication channels Host Client software Buffers Communication flows Channels (Pipes) Device Endpoints Function
Communication channels • communication channel: a logical connection between a device and a software that runs on the host • a device may have a number of communication channels • the host allocates a given bandwidth for every channel according with: • the type of the data transmission and • the available bandwidth • Every channel ends with an endpoint, used to: • configure the data channel • address the channel
Endpoints • Endpoint: a part of a USB device: • it is uniquely identified through a number • ends a communication channel • stores the parameters of a channel: • bus access frequency • required bandwidth • endpoint’s number • behavior in case of an error • maximum length of accepted packages • transfer type • transfer direction
Endpoints • an USB device is a collection of endpoints • every device have two predefined endpoints, one for input and one for output, both on address 0; the other endpoints are not defined • the other endpoints are configured by the host, when the device is connected • the endpoints are for input or for output • a communication channel is identified through: • device address, • the endpoint number and • the dataflow direction
Communication on the USB bus • communication is made through frames of 1 millisecond (1000 cadre/s) • a frame contains a number of transactions • a given transfer may be performed through a number of transactions • Transfer types on the USB bus: • control transfer • isochronous transfer, or periodic • interrupt transfer or a-periodic • bulk transfer or on blocks
Control transfer • initiated by the host, non-periodic • used for configuring and dialog with the device • a control transfer contains: • a “setup” transaction – through which the device is interrogated • zero ore more data transfers transactions • a status transaction – to find the state of the device • the control transfer is performed on a standard channel present in every USB device • the standard channel is used for configuration and for device interrogation • through this channel the host configures all the other channels (including endpoints)
Control transfer • maximum dimension of the control packet may be 8, 16, 32 or 64 bytes • the “setup” packet has a fixed dimension of de 8 bytes • the device descriptor specifies the maximum accepted length for the data packets • the control transfers have lower priority than isochronous or interrupt transfers • at most 10% of a frame is allocated for control transfers, the rest is allocated for isochronous or interrupt transfers • the control transfer used “handshake” in order to guarantee the correctness of the transfer • the erroneous packets are re-transmited
Isochronous transfer (periodical) • assures a guaranteed bandwidth for periodic transfers • the format is not specified by the USB standard; it depends on the type of the device, the content is interpreted only at the client software level • the transfer is continuous, it ends only on an explicit request • a reduced error detection mechanism, the erroneous frames are not re-transmitted • the transfer through an endpoint is made in a single direction; for bidirectional transfer two endpoints must be defined
Isochronous transfer (periodical) • the maximum dimension of a packet is 1023 bytes • if more isochronous devices are used in the same time the the packet dimension is divided accordingly • the system allocates 90% of the bandwidth for isochronous and interrupt transfers • every device will specify the required transfer rate, which may be between 1 and 216 , (one packet per several frames)
Interrupt transfers • used for sporadic, small data transfers • examples: mouse, keyboard, multiple channel devices • maximum packet dimension: 64 bytes • a channel has a guaranteed bandwidth assured through the allocation of a frame portion • during configuration, a minimum appearance period is specified between 1-255 microseconds • during configuration the system verifies if the required bandwidth necessary for a given frequency can be assured
Bulk transfer • used for transferring blocks of data without time restrictions • transfers are non-periodical • examples: printer, digital camera • the transfer will use the maximum available bandwidth • the erroneous packets are re-transmitted • maximum packet dimensions: 8,16, 32, or 64 pt. USB1.1 or 512 for USB 2.0 • the bandwidth is not guaranteed • the priority is minimum
Communication on USB Data Client software USBD interface USB Driver HCD interface Host Controller Driver Transfers Transaction list Transactions Transactions Transaction Hardware interface Host Controller Packets USB
Components involved in the communication • Client software • determines the type of the transfer for each device • it does not handle communication channels • for communication uses the drivers offered by the operating system • USB driver (USBD) • handles the configuration and normal transfer requests received from the client software • establish and configure communication channels based on the received requests; some requests may be rejected because of bandwidth limitations
Components involved in the communication • Host controller’s driver (HCD) • receives transfer requests and handles their transmission • puts the received data in the buffer • checks the transmission limits (requests v.s bandwidth) • announce the end of the transmission • Transaction list • contains the list of transactions in progress • Host controller • transforms the waiting transactions in activities on the bus • handles the frames and send and receive packets
Parallel interface • Transfer is made through a number of lines: • Data lines (ex: 8) – for data transmission • Control lines – for synchronization and dataflow control • Features: • High speed • Small distances • Usually unidirectional transfers • Types of parallel transfers: • a) without control signals • b) asynchronous protocol without confirmation • c) asynchronous protocol with confirmation (hand - shaking)
Transfer types a) Without control signals - only data lines are used - useful for reading status lines or generating command signals - cannot be used for sequential data transfer – there are no signals for synchronization or flow control - examples: testing digital sensors, control of actuators b) asynchronous protocol without confirmation - an extra control signal is used (besides data lines); it may be generated by the emitter or by the receiver - a sequence of data may be transmitted - the transmission speed is controlled by the device generating the control signal - there is no feedback signal (confirmation) from the other partner; the speed should be enough small to cover any possible delays; so the transmission is slow
Parallel transfer c) Asynchronous protocol with confirmation (hand - shaking) - two control signals are used: one from the emitter and one from the receiver - transmission with “feed-back” - it may be adapted to the variable speed of the emitter or receiver devices; the result is a higher speed - if the correlation between control signals is not good errors may occur Correct Error Error
Parallel transfer c) asynchronous protocol (hand - shaking), with inter-conditioning between control signals - solves the correct transmission of data - the control signals are inter-conditioned
Parallel transfer • The I8255 circuit – controller for parallel transfers • 3 data ports of 8 bits (A, B and C) • Working modes: • Inputs • Outputs • Bidirectional transfer • Port C divided in 2 in order to serve as control signals for ports A and B A si B
Counter/Timer circuits • Used for: • counting external events • generate different frequencies by dividing a base clock frequency • delaying signals (mono-stable) • generate periodic interrupts • Specialized controller: I8253 • 3 counters of 16 bits • different working modes • Use in a PC: • to generate interrupts in order to measure the time • periodical memory refresh cycles • to generate simple sounds
Design of an Input/Output interface • Steps • Define the functional block scheme • select circuits for special interface functionalities (controllers) • allocate addresses for registers from the I/O space • establish the selection/decoding mode • design circuits for selection and control. • Functional blocks: • selection/decoding block • Input/Output registers (ports) • Command device • Command register • Status register • Adaptation circuit for the peripheral device
Design of an Input/Output interface • Selection block: • Role: Select the interface and the registers inside it • Selection mode: • Total – all the address lines are considered (rarely used) • Partial – a limited number of address lines are used (most often used) • Linear – every address line is considered a selection lie (used for small, dedicated systems)
Design of an Input/Output interface • Register block: • Data registers/ports – for data transmission: • for Input • for Output • Control register(s) • generate control signals to the peripheral device or determine the working mode of the interface • Status register(s): • show the state of the interface or of the device • Data amplifier: • assures the proper fan-out
Circuits specialized for different interfaces • Parallel interface controller • PIO – parallel I/O: I8255 • Serial interface controller • SIO – serial I/O, or USART – universal serial asynchronous receiver and transmitters: I8251 • Counter/Timer controller: • CTC – counter/timer controller: I8253 • Floppy disk controller: I8272 • DMA controller: I8237 • Interrupt controller: I8259A