CS452 - Real-Time Programming - Fall 2010
Lecture 15 - Serial I/O
Public Service Announcements
- Fourth part of the kernel
- Redo assignment 0 using your kernel
- The A0 implementation you do here is an important debugging tool
while developing your project.
- Improve the robustness of your kernel implementation
- See pdf
The Electrical Environment of the Trains
Why 2400 bps?
1. Conversion of electrical signals into forces
Locomotives
Electric motors.
Power contacts
Switches (Turn-outs)
Solenoids
2. Conversion of forces into electrical signals
Sensors
micro-switches
3. Magnification of electrical signals
Transistors
Relays
4. Communication of locomotives et al with the controller
Track is a sort of primitive ethernet
5. What do you do when the electrical environment gets noisy?
- Slow down
- Push lots of current
- Use capacitors to lower impedance
Features of UARTs
FIFOs
Why do FIFOs exist in UARTS?
The Big Blunder
To use the FIFO effectively you must be able to turn off the transmitter
& receiver independently.
But look at UARTE in UARTxCtrl
- UART Enable.
- If this bit is set to 1, the UART is enabled.
- Data transmission and reception occurs for UART signals.
The Little Blunder
You may have already read the following.
`It is assumed that various configuration registers for the UART are not
written more than once in quick succession, in order to insure proper
synchronization of configuration information across the implementation. Such
registers include UART1Ctrl and UART1LinCtrlHigh. ... In between the two
writes, at least two UARTCLK periods must occur. Under worst case conditions,
at least 55 HCLK periods must separate the two writes. The simplest way to
due [sic] this is separate the two writes by 55 NOPs.'
Why does this occur?
- CPU clocked by CPU clock
- System buses clocked by several different clocks
- UART clocked by its own clock
- The clocks were not suitably synchronized
Why doesn't anybody care about blunders?
- UARTs are used at the beginning of the development process
- Once other I/O (ethernet, USB, etc.) is working, UARTs are no longer
used, except by the boot loader
Interrupts
Five interrupts in the device
- Transmit
- FIFO enabled
- Asserted when transmit FIFO is less than half full.
- Cleared when transmit FIFO is more than half full.
- FIFO disabled
- Asserted when holding register is empty
- Cleared on write to the holding register
- Not conditioned by enable.
- Receive
- FIFO enabled
- Asserted when receive FIFO is half full
- Cleared when receive FIFO is read to less than half full.
- FIFO disabled
- Asserted when receive buffer is full
- Cleared when receive buffer is read
- Modem status
- Asserted when hardware flow control bits change
- Cleared when the modem status register is written
- Receive timeout
- Asserted when receive FIFO is not empty and 32 bit periods pass
with no new data
- Cleared when all data has been read from FIFO
- Combined
- wired OR of the four above interrupts
- Asserted when at least one of the above interrupts is asserted
- Cleared when all the above interrupts are not asserted.
Three inputs to the PIC
- Transmit
- Receive
- Combined
Easy way to use interrupts
Enable only combined; read UART registers to decide what to do.
Think of the receive and transmit parts of the UART as separate state
machines
Handy Features
- Loopback state
- Loopback connector
Return to: