PV198 - I²C 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, Ondřej Bleha, Martin Klimeš, Adam Valt Faculty of Informatics, Masaryk University 7/2024 Introduction I2C FRDM-K66F I²C Accelerometer & Magnetometer Application Homework ·PV198 - I²C ·7/2024 2 / 16 NXP CUP International autonomous cars competition (their website) Working on a group project trying to solve real problems Diverse set of tasks: Reading data from various sensors Designing control algorithm 3D modeling and RC car customization Our team at last year finals Contact: Email: jan.labuda@mail.muni.cz Discord: Ján Labuda / Northeus ·PV198 - I²C ·7/2024 3 / 16 Introduction Intro Switch the branch to Week_07! Discussion of HW6 ·PV198 - I²C ·7/2024 4 / 16 I2C Embedded communication buses SPI – Serial Peripheral Interface I²C – Inter-Integrated Circuit UART – Universal asynchronous receiver / transmitter CAN – Controller Area Network 1-Wire RS-485 RS-232 ·PV198 - I²C ·7/2024 5 / 16 I2C I²C “eye-squared-C” I²C = Inter-Integrated Circuit Invented in 1982 by Philips Semiconductors (now NXP Semiconductors) Applications: intra-board communication Peripherals Sensors ·PV198 - I²C ·7/2024 6 / 16 I2C I²C Principle 2 wires 1. SCL – serial clock 2. SDA – serial data Terminology: controller (= master), target (= slave) Multi-controller & multi-target 100 kbit/s – 5 Mbit/s 7-bit addressing / 10-bit addressing Synchronous Half-duplex ·PV198 - I²C ·7/2024 7 / 16 I2C I²C Schematic Source: https://learn.sparkfun.com/tutorials/i2c/all ·PV198 - I²C ·7/2024 8 / 16 I2C I²C Message Source: K66 Sub-Family Reference Manual, Figure 58-2. ·PV198 - I²C ·7/2024 9 / 16 I2C I²C Principles SCL & SDA are pulled high by pull-up resistors. ACK bit is set by receiving device (active low for acknowledged). Master starts with address transmission – if target exists, it will respond with ACK bit (active low). Controller then continues in either transmit or receive mode (according to the read/write bit it sent), and the target continues in the complementary mode (receive or transmit, respectively). Bits are sent most significant bit first. ·PV198 - I²C ·7/2024 10 / 16 FRDM-K66F I²C FRDM-K66F I²C 4 I²C modules Address match wakeup in low-power modes SMBus support DMA support Functions to use: BOARD_Accel_I2C_Receive BOARD_Accel_I2C_Send ·PV198 - I²C ·7/2024 11 / 16 Accelerometer & Magnetometer Accelerometer & Magnetometer FXOS8700CQ FXOS8700CQ Sensor placed directly on FRDM-K66 development board Datasheet See 10.1. I²C interface See 14. Register description 3-axis linear accelerometer + 3-axis magnetometer combined into a single package ·PV198 - I²C ·7/2024 12 / 16 Accelerometer & Magnetometer FXOS8700CQ I²C Connection FXOS8700CQ connected to I²C bus and 2 GPIO pins FXOS8700CQ K66F Connection SCL PTD8/I2C0_SCL SDA PTD9/I2C0_SDA INT1 PTC17 INT2 PTC13 Source: FRDM-K66F Development Platform User’s Guide, Table 6. ·PV198 - I²C ·7/2024 13 / 16 Application Seminar task Create an application that reads accelerometer output data registers. Print register values into console. Bonus Calculate tilt angle from received values. ·PV198 - I²C ·7/2024 14 / 16 Application Step-by-step guide 1. Download template from study materials in IS. 2. Look at initializeAccel function implementation, pins routing & peripherals. Check if everything is set-up correctly. 3. Read values from sensors in main while loop. 4. Use functions: BOARD_Accel_I2C_Receive BOARD_Accel_I2C_Send 5. For now, ignore setupOrientationDetection functions, it will be used in homework. ·PV198 - I²C ·7/2024 15 / 16 Homework Homework – Orientation Detection 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. Use provided template, write your code into function setupOrientationDetection. ·PV198 - I²C ·7/2024 16 / 16