CS 452/652 Winter 2020 - Lecture 2
January 8, 2020
prev next
Timers
- Chapter 18 in EP93xx User Guide
- memory-mapped device registers
- timer counter width: 16 bit vs 32 bit
- timer mode: free-running vs. periodic
- periodic can be used for interrupt generation
- timer speed: 2 kHz vs. 508 kHz
- debug/watchdog timers: usage optional
- here: no time of day needed, no remote synchronization (very hard problem)
Serial Interface (UART)
- Chapter 14 in EP93xx User Guide
- in particular, read "UART Register Descriptions" in Section 14.1
- ignore "Modem Register Descriptions" starting on Page 14-25
- character device: 1 byte at a time
- memory-mapped device registers
- configuration
- status
- data
- UART1 = COM1, train control, 2400 baud, 8N2, flow control
- UART2 = COM2, terminal, 115200 baud, 8N1, no flow control
Track/Train Specifics
- train speed: 0-14; 15 for reverse
- model trains simulate real-world stopping by gradually slowing down
- we want to preserve this important characteristic
⇒ do not directly reverse rolling train!
- turnout commands: straight, curved
- special command: turn off (last) solenoid
- IMPORTANT: After sending a turnout command, you must wait at least 100ms and at most 500ms. Then, either switch another turnout (which automatically turns off the previous solenoid) or explicitly turn off the last solenoid!
- sensors: query some/all, reset
- read reports after query
- IMPORTANT: operate half-duplex, i.e., do not send train commands while receiving sensor data
Polling Loop with Busy Wait?
for (;;) {
while (!c1);
a1();
while (!c2);
a2();
...
}
cannot handle c2 while waiting for c1, etc...