PV198 - Serial Peripheral Interface One-chip Controllers Daniel Dlhopolček, Marek Vrbka, Jan Koniarik, Oldřich Pecák, Tomáš Rohlínek, Ján Labuda, Jan Horáček, Matúš Škvarla Faculty of Informatics, Masaryk University 6/2023 Embedded communication buses SPI principles SPI in FRDM-K66F Temperature & Pressure sensor Application Homework ·PV198 - Serial Peripheral Interface ·6/2023 2 / 14 Embedded communication buses Intro Switch the branch to Week_06! Discussion of HW5 ·PV198 - Serial Peripheral Interface ·6/2023 3 / 14 Embedded communication buses Embedded communication buses SPI – Serial Peripheral Interface I2C – Inter-Integrated Circuit UART – Universal asynchronous receiver / transmitter CAN – Controller Area Network 1-Wire RS-485 RS-232 ·PV198 - Serial Peripheral Interface ·6/2023 4 / 14 SPI principles What is SPI used for? Intra-board communication Peripherals Sensors ·PV198 - Serial Peripheral Interface ·6/2023 5 / 14 SPI principles SPI 4 wires: 1. Chip Select 2. Clock 3. Master Out Slave In 4. Master In Slave Out Single-master, multi-slave bus Chip Select selects slave for communication Synchronous Full-duplex Possibility to use only 3 wires (only 1 data wire) Source: https://analog.com ·PV198 - Serial Peripheral Interface ·6/2023 6 / 14 SPI principles Timing Source: https://upload.wikimedia.org/wikipedia/commons/b/b6/SPI_timing_diagram.svg ·PV198 - Serial Peripheral Interface ·6/2023 7 / 14 SPI in FRDM-K66F FRDM-K66F SPI 3 SPI modules Master & Slave support Interrupts DMA supports Programmable frame size (4 to 16 bits) 6 peripheral Chip Selects ·PV198 - Serial Peripheral Interface ·6/2023 8 / 14 Temperature & Pressure sensor Bosch BMP280 Datasheet Digital interfaces: 1. I2C (up to 3.4 MHz) 2. SPI (3 and 4 wire, up to 10 MHz) Pressure resolution 0.16 Pa Temperature resolution 0.01 °C Warning Holding any interface pin at a logical high level when VDDIO is switched off can permanently damage the device by excessive current flow through the ESD protection diodes! ·PV198 - Serial Peripheral Interface ·6/2023 9 / 14 Temperature & Pressure sensor BMP280 block diagram Source: BPM280 datasheet ·PV198 - Serial Peripheral Interface ·6/2023 10 / 14 Temperature & Pressure sensor BMP280 SPI Study the datasheet! 4.2 Memory map 5.3 SPI interface 5.3.1 SPI write 5.3.2 SPI read ·PV198 - Serial Peripheral Interface ·6/2023 11 / 14 Application Application Create an application that reads temperature from BMP280 sensor Print temperature into console Wiring BMP280 FRDM-K66P VCC 4 P3V3 GND 14 GND SCL 12 PTC5 SDA 7 PTC6 CSB 4 PTC4 SDO 11 PTC7 See FRDM-K66F Development Platform User’s Guide, p. 23. ·PV198 - Serial Peripheral Interface ·6/2023 12 / 14 Application Step-by-step guide 1. Download template from study materials in IS 2. Look at main function implementation, pins routing & peripherals (DSPI driver) 3. Implement HW-specific functions in sensor.c spi_reg_write spi_reg_read ·PV198 - Serial Peripheral Interface ·6/2023 13 / 14 Homework Homework – communication with BMP280 over SPI Update the application to print pressure as well as temperature. Uncompressed value of the pressure has to appear in the output (like with temperature). ·PV198 - Serial Peripheral Interface ·6/2023 14 / 14