Phillip Stanley-Marbell
Foundations of Embedded Systems
Department of Engineering, University of Cambridge
http://physcomp.eng.cam.ac.uk
Topic 09: Digital Sensor and Actuator I/O
(~30 minutes)
Version 0.2020
(Video)
20
Intended Learning Outcomes for This Topic
2
Design an I2C implementation that trades I/O speed for I/O power
By the end of this topic, you will be able to:
Explain the difference between I2C and SPI
Interpret a SPI/I2C sensor’s datasheet and determine how to control it
Describe common serial I/O interfaces used in embedded systems
Choose sensors with alternative I/O interfaces when SPI/I2C are not a good fit
20
Embedded Systems: Computation + Sensors
3
(a) KL03 ARM Cortex M0+ Microcontroller. (Image: Freescale.)
(b) iCE40 FPGA. (Image: Lattice semiconductor.)
(c) A few sensors. The devices are 3–5mm on a side. (Image: Bosch Sensortec.)
(d) Modern sensor ICs often comprise
a transducer IC paired inside the same
IC package with a mixed-signal IC for
signal conditioning and processing.
(Image: Bosch Sensortec.)
20
This Topic/Chapter 09: Sensor Interfaces
4
Image Source: Bosch Sensortec
20
Sensors Can Have Analog or Digital Interfaces
5
ADXL356 3-axis accelerometer
Source: ADXL356 datasheet
20
Inter-IC Communication (I2C) Serial Bus
6
Pull-up Resistors
SDA
SCL
System
Power
Supply
10kΩ 10kΩ
I/O
Power
Supply
Processor
I2C
Interface
SensorSensor
20
Source: MMA8451Q datasheet
Freescale MMA8451Q 3-Axis Accelerometer with I2C Interface
7
20
Source: L3GD20H datasheet
Example I2C Timing Diagram
8
L3GD20H I2C Slave Timing Diagram
20
Example: MMA8451Q I2C Single Byte Read Transaction
9
Source: MMA8451Q datasheet
20
Freescale MMA8451Q
Source: MMA8451Q datasheet
On-Chip Register Addresses (in addition to I2C addresses)
10
20
Serial Peripheral Interface (SPI)
11
MISO
SCK
System
Power
Supply
MOSI
Processor
SPI
Interface
(SPI Master)
Sensor
I/O Power
Supply
(SPI Slave)
/CS
20
Source: ADXL362 datasheet
Analog Devices ADXL362 3-Axis Accelerometer with SPI Interface
12
20
ADXL362 SPI Register Read
Example SPI Timing Diagram
13
Maximum speed of SPI: ~10Mb/s (compared to 400kb/s for I2C)
20
Analog Devices ADXL362
Source: ADXL362 datasheet
On-Chip Register Addresses (Example: ADXL362)
14
20
Inter-IC Communication (I2C) Serial Bus
15
Pull-up Resistors
SDA
SCL
System
Power
Supply
10kΩ 10kΩ
I/O
Power
Supply
Processor
I2C
Interface
SensorSensor
Recap
20
Source: L3GD20H datasheet
Example I2C Timing Diagram
16
L3GD20H I2C Slave Timing Diagram
Recap
Maximum speed of I2C: 400kb/s
20
Serial Peripheral Interface (SPI)
17
MISO
SCK
System
Power
Supply
MOSI
Processor
SPI
Interface
(SPI Master)
Sensor
I/O Power
Supply
(SPI Slave)
/CS
Maximum speed of SPI: ~10Mb/s (compared to 400kb/s for I2C)
Recap
20
ADXL362 SPI Register Read
Source: ADXL362 datasheet
Example SPI Timing Diagram
18
Recap
20
Further Reading
19
Test your understanding:
▶︎ Complete these online self-assessments on https://f-of-e.org/
To learn more about I2C, see “Understanding the I2C Bus”
▶︎ Like learning to swim, you can’t learn all you need from a textbook
https://f-of-e.github.io/journal-club/1ec4c0852a62877c4bbef4495b244a13.html
Best next step: Get some practice
https://f-of-e.org/chapter-08/#exercises
▶︎ You’ll get some practice in Coursework #2
https://f-of-e.org/chapter-09/#exercises
20
Things to Do
20
Complete a “muddiest point” 2-question survey using this link