Computers, Controllers, and Data Links
Learning Targets
- Situation: Correct converter code with corrupted byte order or missing samples.
- Targets: Registers, data representation, links, buffers and timing.
- Starting data: Twelve-bit code 1241 from the previous 1 V example.
Data Path and Representation
- CPU: Instructions operating on registers and memory.
- Peripheral register: Hardware interface with possible read/write side effects.
- FIFO: First-in, first-out storage with finite capacity.
- Memory-mapped I/O: Register addresses accessed by load/store operations; different semantics from ordinary RAM.
- Code example: 1241 = 0x04D9; big-endian bytes 0x04 then 0xD9.
- Alignment: Low/high bit field and status bits explicitly defined.
- Unsigned N bits: 0 through .
- Two's complement: through .
- Accumulator: 64 × 4095 = 262080; at least 18 unsigned bits.
- Fixed point: Integer plus agreed scale; floating point with finite significant precision.
- Timestamp caution: Binary32 exact consecutive integers only through ; microsecond increments eventually lost.
Memory and Scheduling
- SRAM/DRAM: Direct storage versus refresh-dependent dense storage.
- Nonvolatile memory: Retention with endurance, erase and write-latency limits.
- Polling: Worst-case gap between status checks.
- Interrupt: Event service with masking, entry and priority delays.
- DMA: Peripheral/memory transfers with bus and buffer-ownership requirements.
- Double buffering: Concurrent filling and processing; completion before buffer reuse.
- Example: 256 samples at 1 kS/s → 256 ms block interval; substantial first-sample waiting time.
- Coherency: CPU/cache/DMA agreement on current bytes.
Link Budgets
| Link model | Required agreement | Example duration |
|---|---|---|
| SPI | Polarity/phase, length, order, selection | 16 clocks at 2 MHz → 8 µs |
| I²C | Address, acknowledgment, pull-up, timing | Address plus 2 bytes: 27 clocks at 400 kHz → 67.5 µs |
| UART 8N1 | Baud, start/stop format, voltage levels | 10 line bits per byte |
- Overhead: Selection gaps, commands, start/stop conditions or clock stretching beyond simplified durations.
- UART example: Two bytes/sample at 1 kS/s → at least 20 kbit/s; 17.4% of 115200 bit/s before extra framing.
- Other links: CAN arbitration, USB/Ethernet packets, JTAG state and 1-wire slot timing; device-specific protocols.
- Physical layer: UART logic versus RS-232 bipolar voltages; compatible transceiver required.
- Integrity: Frame boundaries, sequence number and error detection.
- Time meaning: Acquisition timestamp distinct from host arrival.
- Counter wrap: Unsigned difference valid modulo the counter range; actual elapsed interval shorter than one wrap.
Practice
- Preparation: Hand trace or software model; low-aligned twelve-bit code, big-endian two-byte transfer, 1 kS/s.
- Prediction: 0x04/0xD9, 8 µs SPI time, 2000 bytes/s raw storage.
- Execution: Correct transfer, swapped bytes, missing sequence number and 64-sample sum.
- Observation: Word format, acquisition time and arrival time separately.
| Item | Expected | Trace/result |
|---|---|---|
| Code frame | 0x04, 0xD9 | — |
| SPI duration | 8 µs plus overhead | — |
| Raw storage | 2000 bytes/s | — |
| Accumulator | At least 18 bits | — |
- Optional extension: 100 ms versus 300 ms processing per 256 ms block.
- Carry forward: Frame format, link budget and buffer deadline.
Exercises
- Bytes: Big-endian two-byte representation of 0x0123.
- SPI: Twenty-four clock periods at 2 MHz.
- UART: Line rate for three bytes/sample, 1 kS/s, 8N1.
- Sum: Bits required for 16 maximum twelve-bit codes.
- Buffer: Fill time for 128 samples at 2 kS/s.
Answers and reasoning
- Answer: 0x01 then 0x23.
- Answer: 12 µs before overhead.
- Answer: At least 30 kbit/s.
- Answer: 16 unsigned bits; maximum sum 65520.
- Answer: 64 ms.
Continue
- Previous: Digital Meets Analog
- Next: Microcontrollers
Reference
- Reading: Paul Horowitz and Winfield Hill, The Art of Electronics, third edition, Chapter 14.
- Lesson material: Original explanations, calculation examples and exercises; reference sections for further study.