ECE 320 · Week 7
Modern Computer: Embedded Systems
How an I2C address byte differs from an SPI chip-select edge.
Week 7 of 10 · Das Frite
ECE 320 · Week 7 · In class
How an I2C address byte differs from an SPI chip-select edge.
- An I2C address byte is a value on the wire that names a device.
- An SPI chip-select edge is a pin that selects a device before the bytes move.
- The project uses two of I2C, SPI, and UART.
ECE 320 · Week 7 · In class
The lab captures one I2C transaction to the DS3231 and one SPI transaction through the MCP3008.
- Label the address or the chip select, and the bytes.
- The proposal names the two buses the project will use and says, against one stated requirement, why the project needs Linux rather than a microcontroller.
- The homework is the comparison, with no capture attached.
ECE 320 · Week 7 · Lecture
Two buses on one header
- Ground
- I2C
- SPI
Other pins are dimmed. Colours as on the Das Frite pinout, where each pin's name is. The square pad is pin 1.
ECE 320 · Week 7 · Lecture
An I2C transaction
- Start: SDA falls while SCL is high.
- First byte: a 7-bit address, then one bit for read (1) or write (0).
- The addressed device pulls SDA low for one clock: ACK. No device, no ACK.
- Data bytes follow, each with its own ACK, then a stop: SDA rises while SCL is high.
Two wires, shared by every device on the bus, with pull-up resistors.
ECE 320 · Week 7 · Lecture
An SPI transaction
- The controller drives one device's chip select (CS) to its active level, usually low.
- It clocks SCLK; each clock moves one bit out on MOSI and one bit in on MISO at the same time.
- When enough bytes have moved, CS returns to inactive.
Every device gets its own CS line. The clock polarity and phase (the SPI mode) must match the device's datasheet.
ECE 320 · Week 7 · Lecture
Getting a clean capture
- Connect the analyser's ground to the board's ground first.
- Sample several times faster than the bus clock, or edges will be misplaced.
- Trigger on the line that starts a transaction, so the capture begins there.
- Turn on the protocol decoder for the bus and check its settings match the wiring.
ECE 320 · Week 7 · Lecture
Linux, or a microcontroller?
| Points to Linux | Points to a microcontroller |
|---|---|
| Networking, a file system, many processes | Hard timing in microseconds |
| Large existing software to reuse | Instant start, low standby power |
| Updates and remote login | Simple, single job, low cost |
The proposal argues one stated requirement, not the whole table.
ECE 320 · Week 7 · Lab
Lab
- On the logic analyser, capture one I2C transaction to the DS3231 and one SPI transaction through the MCP3008.
- Label the address or the chip select and the bytes. Write a one-page proposal that names the two buses the project will use and says, against one stated requirement, why the project needs Linux rather than a microcontroller. Second pass: capture each bus once more and keep the second files in your notes.
ECE 320 · Week 7 · Lab
Lab (continued)
- Assemble the lab hand-in: One decoded I2C capture and one decoded SPI capture, each labeled with the address or the chip select and the bytes, and a one-page proposal that names the two buses and the reason the project needs Linux rather than a microcontroller.
ECE 320 · Week 7 · Lab
Hand in
One decoded I2C capture and one decoded SPI capture, each labeled with the address or the chip select and the bytes, and a one-page proposal that names the two buses and the reason the project needs Linux rather than a microcontroller.
ECE 320 · Week 7 · Homework
Homework
- Write how you tell an I2C address byte from an SPI chip-select edge, with no capture attached.
ECE 320 · Week 7 · Homework
Turn in
That comparison.
ECE 320 · Week 7 · Read
Read
On the lab site: Module 10, I/O. This week grades the two labeled captures and the proposal.
ECE 320 · Week 7 · Next
Week 8
A mocked bus returns a sample the library asked for.