CS452 - Real-Time Programming - Fall 2010
Lecture 3 - I/O Devices
Pubilic Service Announcements
- Assignment 0 Deadline
- More about serial I/O: pdf
The Hardware
Provided and maintained by CSCF
- Linux systems
- cross compiler: runs on 86_64, produces code for ARM
- GNU toolchain: compiler, assembler, link editor
- You will notice that my makefile separates
- compilation to assembly code,
- assembling the assembly code, and
- link editing.
- need to login explicitly to
linux.student.cs
- TFTP servers
- need to type IP number explicitly
TS-7200
`COM' ports
Connected to UARTs
Only really two
Ethernet port
Reset switch
EP-9302
System on chip
- ARM 920T core, implementing ARM v4T instruction set
- Two co-processors
- System controller, MMU
- Maverick Crunch floating point unit, mainly used for signal
processing
- Peripherals
- UARTs
- Timers
- DIO
- A/D
- etc.
Memory
Byte addressable, word size 32 bits
- 32 Mbytes of RAM, starting at 0x00000000
- lowest RAM has code to access exception handlers
- above that is RedBoot, which you do not want to overwrite
- 4 Mbytes of flash RAM, starting at 0x60000000
- Contains RedBoot, which is loaded into RAM at startup
- Device registers above 0x80000000
Separate instruction and data caches
- Not turned on for RedBoot
The Software
Compiler
GNU tool chain
- when you are getting started optimizing is a bad idea
- software multiplication, division, floating point from libgcc.a
- Makefile
- target.ld
RedBoot
Partial implementation
- fconfig :: NOT
- load (tftp)
- examine, copy, fill memory
Returns when program terminates
Busy-wait IO
COM2 uses monitor; COM1 goes to train
- initialization/configuration
- output
- input
For assignment 0 you need to increase the functionality.
Bug in one function
How Timers Work
Set them up
- how far to count, which is the length of the counting cycle
- calculate from their own clock speed and the tick rate you want
Start them counting
- once started they count forever
Whenever they count through zero they trigger an interrupt.
- You have interrupts turned off, but
- You could enable interrupts in the timer and look for a bit set in the
ICU
A better solution for this assignment
- Let the timer count continuously and test for roll-over
Read the documentation carefully.
Data Communication using RS-232
Communication protocol existing since forever.
- description of a wire, and the signals on it.
Why do we still use it in the age of USB, etc.
- simple
- inexpensive
- robust
- easy to implement, especially by doing busy-wait
When you get a brand new board
- Using JTAG
- blink the LEDs on the board
- put in a primitive loader comunicating by serial I/O
- Using the primitive loader and serial I/O
- configure a boot loader like RedBoot
- download the boot loader using serial I/O
- use the capabilities of the running boot loader to put the boot
loader into Flash
- Reset puts you into the boot loader
- configure the ethernet and use it for loading
- when you start up the image you loaded you are completely on your
own
- prove that your code is running using serial I/O
Serial Hardware: the Universal Asynchronous Receiver Transmitter
(UART)
Really nothing but two shift registers
- Parallel to serial for output
- Serial to parallel for input
Also must
- Add start and stop bits
- Provide a clock
- Detect error conditions
Finally there is a bus interface
Very simple RS-232
Three wires
Wired like this
GND ---------- GND
XMIT --\ /---- XMIT
X
RCV----/ \---- RCV
What could be simpler?
- BUT, ...
- This is actually called a null modem.
- To see why we need to look at the pins on the connector.
Less Simple RS-232
Distinguish Data Terminal Equipment (DTE) from Data Circuit-terminating
Equipment (DCE)
On the DE-9 connector we have for DTE
5 -- GND
3 -- XMIT
2 -- RCV
and for DCE
5 -- GND
3 -- RCV
2 -- XMIT
A very simple `straight through' cable connects these perfectly. But when
we conect DTE to DTE we need the cable above, which is called a `null
modem'.
Train RS-232
Three wire works fine as long as both ends of the wire are much faster
than the wire itself. But the train controller is very slow. Why?
- Wait for mechanical sensors.
- High electrical noise
The train controller needs to be able to say STOP, I can't take any
more
Software Flow Control
XOFF, XON
Hardware Flow Control
CTS, RTS or DTR, DSR
What Happens if You Omit Flow Control
- Bytes get dropped
- Bytes get corrupted
- The train controller hangs
Return to: