UART Project - Advanced System Programming - Lecture Slides, Slides of Computer Applications

Main points are: Uart Project, Linux Device-Drivers, Serial-Port Controller, Universal Asynchronous Receiver-Transmitter, Machine-Code Details, Pc-To-Pc Communications, Device-Driver Module, Kudlick Classroom, Linux Char

Typology: Slides

2012/2013

Uploaded on 04/17/2013

pamelaaaa
pamelaaaa 🇮🇳

4.5

(12)

103 documents

1 / 43

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The UART project
Applying what we’ve learned
about Linux device-drivers to the
PC’s serial-port controller
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b

Partial preview of the text

Download UART Project - Advanced System Programming - Lecture Slides and more Slides Computer Applications in PDF only on Docsity!

The UART project

Applying what we’ve learned

about Linux device-drivers to the

PC’s serial-port controller

Project’s purpose

  • Allow you to gain experience encountering

the kinds of issues that commonly arise in

crafting software to operate real hardware:

  • Learning the hardware device’s capabilities
  • Deciding which driver-methods to implement
  • Accommodating your platform’s interfaces
  • Exploiting the OS kernel’s support-functions
  • Devising a strategy for testing and debugging

Tx and Rx

  • The UART has a transmission-engine, and

also a reception-engine, which are able to

operate simultaneously (i.e., “full-duplex”)

  • Software controls the UART’s operations

by accessing several registers, using the

x86 processor’s ‘in’ and ‘out’ instructions

  • Linux provides some convenient ‘macros’

that ‘hide’ the x86 machine-code details

PC-to-PC communications

rackmount PC system

student workstation

KVM cable

rackmount PC system

student workstation

KVM cable

‘ null-modem’ serial cable

ethernet cables

Kudlick Classroom

Indicates a “null-modem” PC-to-PC serial cable connection

lectern

Linux char-driver components

init

exit

fops

function

function

function

...

Device-driver LKM layout

registers the ‘fops’

unregisters the ‘fops’

module’s ‘payload’ is a collection of callback-functions having prescribed prototypes

AND

a ‘package’ of function-pointers

the usual pair of module-administration functions

‘write()’ and ‘read()’

  • Obviously your driver-module’s ‘payload’

will have to include ‘methods’ (functions)

which perform the ‘write()’ and ‘read()’

operations that applications will invoke

  • You may decide your driver needs also to

implement certain additional ‘methods’

  • A little history is helpful for understanding

some of the UART device’s terminology

DCE and DTE

  • Original purpose of the UART was for PCs

to communicate via the telephone network

  • Telephones were for voice communication

(analog signals) whereas computers need

so exchange discrete data (digital signals)

  • Special ‘communication equipment’ was

needed for doing the signal conversions

(i.e. a modulator/demodulator, or modem )

Serial data-transmission

The Transmitter Holding Register (8-bits)

The transmitter’s internal ‘shift’ register

clock

Software outputs a byte of data to the THR

The bits are immediately copied into an internal ‘shift’-register

The bits are shifted out, one-at-a-time, in sync with a clock-pulse

start bit

stop bit

data-bits

clock-pulses trigger bit-shifts Docsity.com

Serial data reception

clock

input voltage

clock-pulses trigger voltage-sampling and bit-shifts at regular intervals

The receiver’s internal ‘shift’ register

1- 0-1-1-0-0-0-0-1 -

start bit

stop bit

data-bits

The Receiver Buffer Register (8-bits)

Software can input the received byte from the RBR

Signal functions

  • CD: Carrier Detect The modem asserts

this signal to indicate that it successfully

made its connection to a remote device

  • RI: Ring Indicator The modem asserts

this signal to indicate that the phone is

ringing at the other end of its connection

  • DSR: Data Set Ready Modem to PC
  • DTR: Data Terminal Ready PC to Modem

Signal functions (continued)

  • RTS: Request To Send PC is ready for

the modem to relay some received data

  • CLS: Clear To Send Modem is ready for

the PC to begin transmitting some data

The 16550 UART registers

Transmit Data Register

Received Data Register

Interrupt Enable Register

Interrupt Identification Register

FIFO Control Register

Line Control Register

Modem Control Register

Line Status Register

Modem Status Register

Scratch Pad Register

Divisor Latch Register 16-bits (R/W)

8-bits (Write-only)

8-bits (Read-only)

8-bits (Read/Write)

8-bits (Read-only)

8-bits (Write-only)

8-bits (Read/Write)

8-bits (Read/Write)

8-bits (Read-only)

8-bits (Read-only)

8-bits (Read/Write)

Base+

Base+

Base+

Base+

Base+

Base+

Base+

Base+

Base+

Base+

Base+

Rate of data-transfer

  • The standard UART clock-frequency for

PCs equals 1,843,200 cycles-per-second

  • Each data-bit consumes 16 clock-cycles
  • So the fastest serial bit-rate in PCs would

be 1843200/16 = 115200 bits-per-second

  • With one ‘start’ bit and one ‘stop’ bit, ten

bits are required for each ‘byte’ of data

  • Rate is too fast for ‘teletype’ terminals