PV198 – One-chip Controllers, I2C / Dávid Danaj 1 PV198 – One-chip Controllers I2C PV198 – One-chip Controllers, I2C / Dávid Danaj NXPCUP 1.International competition with autonomous cars. 2.FI Team: -Write email to 492926 to register (until 28.10.) -You will get a task to solve -Recruitment until 12.12. – we will pick the top students - • 2 PV198 – One-chip Controllers, I2C / Dávid Danaj 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 • 3 PV198 – One-chip Controllers, I2C / Dávid Danaj What is I2C §I2C – Inter-Integrated Circuit §Invented in 1982 by Philips Semiconductor (now NXP Semiconductors) • • 4 PV198 – One-chip Controllers, I2C / Dávid Danaj What is it used for §Intra-board communication • §Peripherals §Sensors • • • • • 5 How does it work PV198 – One-chip Controllers, I2C / Dávid Danaj §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 • 6 How does it work – Scheme PV198 – One-chip Controllers, I2C / Dávid Danaj 7 https://learn.sparkfun.com/tutorials/i2c/all How does it work – Message PV198 – One-chip Controllers, I2C / Dávid Danaj 8 K66 Sub-Family Reference Manual, Figure 58-2. FRDM-K66F I2C §4 I2C modules §Address match wakeup in low power modes §SMBus support §Methods to use: §BOARD_I2C_Receive §BOARD_I2C_Send • PV198 – One-chip Controllers, I2C / Dávid Danaj 9 Accelerometer & Magnetometer §FXOS8700CQ – link §3-axis, linear accelerometer + 3-axis, magnetometer combined into a single package • PV198 – One-chip Controllers, I2C / Dávid Danaj 10 Accelerometer & Magnetometer §Connected to I2C bus and 2 GPIO signals • PV198 – One-chip Controllers, I2C / Dávid Danaj Freedom FRDM-K66F Development Platform User’s Guide, Table 6. 11 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 12 Application §Create an application that reads accelerometer output data registers -Study the datasheet! §Print register values into console §Trap: Check configuration of pins and peripherals •Bonus: §Calculate tilt angle from received values PV198 – One-chip Controllers, I2C / Dávid Danaj 13 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 14 Homework §Write your code into method setupOrientationDetection() • §Link to Application note: AN4068 • PV198 – One-chip Controllers, I2C / Dávid Danaj 15