PV198 – One-chip Controllers, I2C / Dávid Danaj 1 PV198 – One-chip Controllers I2C PV198 – One-chip Controllers, I2C / Dávid Danaj 2 Content 1.What is I2C 2.What is it used for 3.How does it work 4.FRDM-K66F I2C 5.Accelerometer & Magnetometer 6.Application § PV198 – One-chip Controllers, I2C / Dávid Danaj 3 What is I2C §I2C – Inter-Integrated Circuit §Invented in 1982 by Philips Semiconductor (now NXP Semiconductors) § § PV198 – One-chip Controllers, I2C / Dávid Danaj 4 What is it used for §Intra-board communication § §Peripherals §Sensors § § § § § How does it work PV198 – One-chip Controllers, I2C / Dávid Danaj 5 §2 wires (Clock – SCL, Data – SDA) – pulled high §Multi-master & multi-slave §100 kbit/s – 5 Mbit/s §7-bit addressing / 10-bit addressing §Synchronous §Half-duplex § How does it work – Scheme PV198 – One-chip Controllers, I2C / Dávid Danaj 6 https://learn.sparkfun.com/tutorials/i2c/all How does it work – Message PV198 – One-chip Controllers, I2C / Dávid Danaj 7 K66 Sub-Family Reference Manual, Figure 58-2. FRDM-K66F I2C §4 I2C modules §Address match wakeup in low power modes §SMBus support §DMA support §Methods to use: §BOARD_I2C_Receive §BOARD_I2C_Send § PV198 – One-chip Controllers, I2C / Dávid Danaj 8 Accelerometer & Magnetometer §FXOS8700CQ – link §3-axis, linear accelerometer + 3-axis, magnetometer combined into a single package § 9 PV198 – One-chip Controllers, I2C / Dávid Danaj Accelerometer & Magnetometer §Connected to I2C bus and 2 GPIO signals § 10 PV198 – One-chip Controllers, I2C / Dávid Danaj Freedom FRDM-K66F Development Platform User’s Guide, Table 6. Application – Template §startInitialization (check sensor ID, wake-up) §setupOrientationDetection (enable detection, interrupts, etc.) – Homework §finishInitialization (setup frequency, activate sensor) § § PV198 – One-chip Controllers, I2C / Dávid Danaj 11 Application §Create an application that reads accelerometer output data registers §Print register values into console § §Bonus: §Calculate tilt angle from received values PV198 – One-chip Controllers, I2C / Dávid Danaj 12 Homework §Create an application that detects orientation of the board (the same way as mobile phones do) §Use the feature of the sensor – do not calculate it in the MCU from XYZ register values §Use interrupt from sensor §Print current orientation into console when orientation of the board changes PV198 – One-chip Controllers, I2C / Dávid Danaj 13 Homework §Write your code into method setupOrientationDetection() § §Link to Application note: AN4068 § PV198 – One-chip Controllers, I2C / Dávid Danaj 14