Serial protocols
Đã giới thiệu| English | Ý nghĩa |
|---|---|
| UART | cổng truyền nhận song song bất đồng bộ |
| baud rate | baud rate |
| SPI | giao diện ngoại vi serial |
| chip-select | chip-select |
| I2C | I2C |
Three wires, three contracts
- UART sends asynchronous bytes: no shared clock, just start bit, 8 data bits, stop bit, at a baud rate both ends agreed on. One 8N1 byte = exactly 10 bit times.
- SPI shares a clock (SCLK) with a chip-select per device — full duplex. I2C runs the board on two open-drain wires with 7-bit addresses.

At 115 200 baud: 11 520 bytes/s, one byte 86.8 µs. Eleven bytes fit a 1 ms loop ✓; a 100-byte burst (8.68 ms) does not — sizing decides, not preference.
{exercise:uni-ee0851-uart}
At 115 200 baud, 8N1, one byte occupies —
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
8N1 = 10 bits per byte; 10/115 200 = 86.8 µs. The framing bits are part of the price.
A datasheet quotes an I2C slave address as 0x48. This is —
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
I2C addresses are 7 bits; the 8th bit of the address byte is the read/write flag. Datasheets quote both forms — know which you are reading.
Price the wire against the speed
- SPI at 10 MHz: 0.8 µs per byte — about 108× the UART here, one extra wire per device. I2C at 400 kHz: ~20 µs per byte, two wires for the whole board.
- Sensor on I2C, flash on SPI, console on UART: each priced by this arithmetic.
{exercise:uni-ee0852-price}
SPI at 10 MHz vs UART at 115 200: the byte-time ratio is about —
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
86.8 µs / 0.8 µs ≈ 108. The clock line is the speed; the wire per device is the price.