CS452 - Real-Time Programming - Spring 2010
Public Interest Announcements
Lecture 17 - Serial I/O: Implementation
Implementation
The simplest way to handle the interrupts is to turn on only the combined
interrupt and then look at the registers of the device.
To identify the current interrupt
Read UARTxIntIDIntClr at 0x800[bc]001c
- Four bits, one for each interrupt
- (Write anything to this register to clear the modem status
interrupt)
When service is required
Transmitting
- Initialization
- Enable modem status interrupt (UARTxCtrl)
- When bytes arrive to transmit
- Add bytes to end of buffer
- Test modem status
- If OK to send
- Test transmitter busy: (UARTxFlag at 0x800[bc]0018)
- If busy
- enable transmit interrupt (UARTxCtrl at 0x800[bc]0014)
- else
- write first byte to hold register
- If more bytes to transmit
- enable transmit interrupt (UARTxCtrl at
0x800[bc]0014)
- On transmit interrupt
- Test modem status
- If OK to send
- write first byte to hold register
- if no more bytes to transmit
- disable transmit interrupt
- else
- disable transmit interrupt
- On modem status interrupt
- If OK to send
- Test transmitter busy
- If busy
- Enable transmit interrupt
- else
- if bytes to transmit
- write first byte to hold register
- if more bytes to transmit
- enable transmit interrupt.
Receiving
- Getting started
- Read data in register and discard it
- Turn on receiver
- Enable Receive interrupt
- Receive interrupt
Task Structure
We are supposed to support
int Get( int port )
and
int Put( int port, char c )
These are wrappers for sends to one or more serial servers.
- On Get the server blocks the client until data is available
- Does a non-blocking TryGet give you anything you cannot do with
task structure?
- Put is non-blocking. The only guarantee is that the character has been
added to a buffer of characters to be transmitted
How many servers and notifiers?
|
one server |
two servers |
four servers |
| one
notifier
|
likely queue
congestion in
server
|
|
likely queue
congestion
in notifer
|
| two
notifiers
|
one per channel?
one per direction?
|
how should they
be paired?
|
|
| four
notifiers
|
certain queue
congestion
in server
|
likely queue
congestion in
server
|
best performance,
most tasks
|
How should we handle a terminal?
Issues
- Line editing
- undefined intermediate states
- well-defined trigger
- Echo
Either
- one server per channel,
- passing characters from one notifier to the other
Or
- courier connecting receive server to transmit server
- What characteristics does the terminal have? termcap follies
Many other issues come up below as we consider possible task
structures.
Return to: