MCUXpresso SDK Documentation

lpi2c_read_fxls897x_accel_value_transfer

lpi2c_read_fxls897x_accel_value_transfer#

Overview#

The lpi2c_read_fxls897x_accel_value example shows how to use LPI2C driver to communicate with an i2c device:

  1. How to use the lpi2c driver to read a i2c device who_am_I register.

  2. How to use the lpi2c driver to write/read the device registers.

In this example, the values of three-axis accelerometer print to the serial terminal on PC through the virtual serial port on board.

Running the demo#

When the example runs successfully, you can see the similar information from the terminal as below.

LPI2C example -- Read Accelerometer Value
Found an FXLS8974 on board, the device address is 0x18.
The accel values:
x =    18 , y =   -23 , z =  1050
x =    18 , y =   -23 , z =  1050
x =    14 , y =   -23 , z =  1044
x =    14 , y =   -23 , z =  1044
x =    14 , y =   -23 , z =  1044
x =     7 , y =   -12 , z =  1072
x =     7 , y =   -12 , z =  1072
x =    18 , y =   -35 , z =  1044
x =    18 , y =   -35 , z =  1044
x =    18 , y =   -35 , z =  1044

End of LPI2C example.

Supported Boards#

FRDM-MCXE247
Hardware requirements
  • USB-C cable

  • FRDM-MCXE247 board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a USB cable between the host PC and the MCU-LINK USB port on the target board.

  2. Open a serial terminal with the following settings:

  • 115200 baud rate

  • 8 data bits

  • No parity

  • One stop bit

  • No flow control

  1. Download the program to the target board.

  2. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXL255
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXL255 board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a USB Type-C cable between the host PC and the MCU-Link USB port (J16) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The following lines are printed to the serial terminal when the demo program is executed.

LPI2C example -- Read Accelerometer Value
Found an FXLS8974 on board, the device address is 0x18.
The accel values:
x =    18 , y =   -23 , z =  1050
x =    18 , y =   -23 , z =  1050
x =    14 , y =   -23 , z =  1044
x =    14 , y =   -23 , z =  1044
x =    14 , y =   -23 , z =  1044
x =     7 , y =   -12 , z =  1072
x =     7 , y =   -12 , z =  1072
x =    18 , y =   -35 , z =  1044
x =    18 , y =   -35 , z =  1044
x =    18 , y =   -35 , z =  1044

End of LPI2C example.