PV198 – One-chip Controllers, SPI / Dávid Danaj 1 PV198 – One-chip Controllers SPI PV198 – One-chip Controllers, SPI / Dávid Danaj 2 Content 1.What is SPI 2.What is it used for 3.How does it work 4.FRDM-K66F SPI 5.Sensor – BMP 280 6.Application § PV198 – One-chip Controllers, SPI / Dávid Danaj 3 What is SPI §SPI – Serial Peripheral Interface § §Serial interface bus PV198 – One-chip Controllers, SPI / Dávid Danaj 4 What is it used for §Intra-board communication § §Peripherals §Sensors § § § § § How does it work – Scheme PV198 – One-chip Controllers, SPI / Dávid Danaj 5 Figure 1. SPI configuration with master and a slave https://www.analog.com/en/analog-dialogue/articles/introduction-to-spi-interface.html How does it work PV198 – One-chip Controllers, SPI / Dávid Danaj 6 §4 wires (Clock, Chip Select, Master In Slave Out, Master Out Slave In) §Single-master & multi-slave §Chip Select selects slave for communication §Synchronous §Full-duplex §Possibility to use only 3 wires (only 1 data wire) How does it work – Message PV198 – One-chip Controllers, SPI / Dávid Danaj 7 By SPI_timing_diagram.svg: en:User:Cburnettderivative work: Jordsan (talk) - SPI_timing_diagram.svg, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=11405368 FRDM-K66F SPI §3 SPI modules §Master & Slave support §Interrupts §DMA support §Programmable frame size (4 to 16 bits) §6 peripheral Chip Selects § PV198 – One-chip Controllers, SPI / Dávid Danaj 8 Temperature & Pressure sensor §Bosch BMP280 Digital Pressure Sensor – link §Digital interfaces I²C (up to 3.4 MHz) SPI (3 and 4 wire, up to 10 MHz) §Pressure resolution 0.16 Pa §Temperature resolution 0.01°C § § § 9 PV198 – One-chip Controllers, SPI / Dávid Danaj BMP 280 PV198 – One-chip Controllers, SPI / Dávid Danaj 10 BMP 280 SPI PV198 – One-chip Controllers, SPI / Dávid Danaj 11 BST-BMP280-DS001-11 BMP 280 SPI – Write PV198 – One-chip Controllers, SPI / Dávid Danaj 12 BMP 280 SPI – Read PV198 – One-chip Controllers, SPI / Dávid Danaj 13 Application §Create an application that reads temperature from BMP280 sensor §Print temperature into console PV198 – One-chip Controllers, SPI / Dávid Danaj 14 Accelerometer & Magnetometer 15 PV198 – One-chip Controllers, SPI / Dávid Danaj GND VCC SCL SDA CSB Temp & Pressure Sensor BMP 280 SDO Application – Step-by-step guide 1.Study BMP280 Datasheet 2.Study Serial Peripheral Interface (SPI) chapter in MCU Reference manual 3.Setup pin routing 4.Setup DSPI peripheral driver (speed, timing, etc.) 5.Download BMP280_driver and temperature example 6.Import driver to the project, use example code 7.Implement HW specific functions – your main task 8.Repeat steps 1-7 if necessary PV198 – One-chip Controllers, SPI / Dávid Danaj 16 Application – Template 1.Study BMP280 Datasheet 2.Study Serial Peripheral Interface (SPI) chapter in MCU Reference manual 3.Setup pin routing 4.Setup DSPI peripheral driver (speed, timing, etc.) 5.Download BMP280_driver and temperature example 6.Import driver to the project, use example code 7.Implement HW specific functions – your main task 8.Repeat steps 1, 2 and 7 if necessary PV198 – One-chip Controllers, SPI / Dávid Danaj 17 Checkmark Checkmark Checkmark Checkmark Application – Template PV198 – One-chip Controllers, SPI / Dávid Danaj 18 §Check pin routing §Check DSPI configuration §Check timing §Check sensor.c/.h files Homework §Update the application to print pressure as well as temperature PV198 – One-chip Controllers, SPI / Dávid Danaj 19