MCUXpresso SDK Documentation

i2c_read_fxls89xx_accel_value_transfer

i2c_read_fxls89xx_accel_value_transfer#

Overview#

The i2c_read_fxls89xx_accel_value example shows how to use LPC I2C driver to communicate with an lpc_i2c device:

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

  2. How to use the lpc_i2c 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.

Supported Boards#

FRDM-MCXW23
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXW23 Board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a USB cable between the host PC and the FRDM board J10.

  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

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

I2C example – Read Accelerometer Value Found an FXLS8974 on board, the device address is 0x19. The accel values: x = -4 , y = 19 , z = 1042 x = -4 , y = 19 , z = 1042 x = -4 , y = 19 , z = 1042 x = 0 , y = 7 , z = 1029 x = 0 , y = 7 , z = 1029 x = 11 , y = 23 , z = 1046 x = 11 , y = 23 , z = 1046 x = 7 , y = 23 , z = 1022 x = 7 , y = 23 , z = 1022 x = 7 , y = 23 , z = 1022

End of I2C example.

MCXW23-EVK
Hardware requirements
  • Mini/micro USB cable

  • MCXW23-EVK Board

  • Personal Computer

Board settings

Apply the jummpers on J13 1-2, 9-10 and 13-14.

Prepare the Demo
  1. Connect a USB cable between the host PC and the EVK board J33.

  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

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

I2C example – Read Accelerometer Value Found an FXLS8974 on board, the device address is 0x18. The accel values: x = 15 , y = 11 , z = 1119 x = 15 , y = 11 , z = 1119 x = 15 , y = 11 , z = 1119 x = 3 , y = 3 , z = 1077 x = 3 , y = 3 , z = 1077 x = 23 , y = -8 , z = 1127 x = 23 , y = -8 , z = 1127 x = -4 , y = -12 , z = 1096 x = -4 , y = -12 , z = 1096 x = -4 , y = -12 , z = 1096

End of I2C example.