MCUXpresso SDK Documentation

lpi2c_read_fxls896x_accel_value_transfer

lpi2c_read_fxls896x_accel_value_transfer#

Overview#

The lpi2c_read_fxls896x_accel_value example shows how to use LPI2C driver to communicate with an lpi2c device:

  1. How to use the lpi2c driver to read a lpi2c 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.

Supported Boards#

FRDM-MCXW71
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXW71 Board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these 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.

  5. Please note, this example could only run on the EVK 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 FXLS8964 on board , the device address is 0x19 . The accel values: x = 11 , y = -103 , z = 1071 x = 11 , y = -103 , z = 1071 x = 11 , y = -103 , z = 1071 x = 15 , y = -130 , z = 1085 x = 15 , y = -130 , z = 1085 x = 3 , y = -126 , z = 1066 x = 3 , y = -126 , z = 1066 x = 0 , y = -111 , z = 1070 x = 0 , y = -111 , z = 1070 x = 0 , y = -111 , z = 1070

End of LPI2C example.

MCX-W71-EVK
Hardware requirements
  • Type-C USB cable

  • MCX-W71-EVK Board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these 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.

  5. Please note, this example could only run on the EVK 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 FXLS8964 on board , the device address is 0x19 . The accel values: x = 11 , y = -103 , z = 1071 x = 11 , y = -103 , z = 1071 x = 11 , y = -103 , z = 1071 x = 15 , y = -130 , z = 1085 x = 15 , y = -130 , z = 1085 x = 3 , y = -126 , z = 1066 x = 3 , y = -126 , z = 1066 x = 0 , y = -111 , z = 1070 x = 0 , y = -111 , z = 1070 x = 0 , y = -111 , z = 1070

End of LPI2C example.

FRDM-MCXW72
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXW72 Board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these 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.

  5. Please note, this example could only run on the FRDM 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 FXLS8964 on board , the device address is 0x19 . The accel values: x = 122 , y = 761 , z = 376 x = 122 , y = 761 , z = 376 x = 122 , y = 761 , z = 376 x = 125 , y = 680 , z = 470 x = 125 , y = 680 , z = 470 x = 163 , y = 664 , z = 708 x = 163 , y = 664 , z = 708 x = 102 , y = 657 , z = 931 x = 102 , y = 657 , z = 931 x = 102 , y = 657 , z = 931

End of LPI2C example.

KW45B41Z-EVK
Hardware requirements
  • Mini/micro USB cable

  • KW45B41Z-EVK Board

  • Personal Computer

Board settings

Disconnect JP30.

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these 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.

  5. Please note, this example could only run on the EVK 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 FXLS8964 on board , the device address is 0x19. The accel values: x = -125 , y = 12 , z = 976 x = -125 , y = 12 , z = 976 x = -125 , y = 12 , z = 976 x = -125 , y = 24 , z = 976 x = -125 , y = 24 , z = 976 x = -134 , y = 16 , z = 984 x = -134 , y = 16 , z = 984 x = -134 , y = 4 , z = 976 x = -134 , y = 4 , z = 976 x = -134 , y = 4 , z = 976

End of LPI2C example.

KW47-EVK
Hardware requirements
  • Type-C USB cable

  • KW47-EVK Board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these 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.

  5. Please note, this example could only run on the EVK 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 FXLS8964 on board , the device address is 0x19 . The accel values: x = 122 , y = 761 , z = 376 x = 122 , y = 761 , z = 376 x = 122 , y = 761 , z = 376 x = 125 , y = 680 , z = 470 x = 125 , y = 680 , z = 470 x = 163 , y = 664 , z = 708 x = 163 , y = 664 , z = 708 x = 102 , y = 657 , z = 931 x = 102 , y = 657 , z = 931 x = 102 , y = 657 , z = 931

End of LPI2C example.

MCX-W72-EVK
Hardware requirements
  • Type-C USB cable

  • MCX-W72-EVK Board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these 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.

  5. Please note, this example could only run on the EVK 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 FXLS8964 on board , the device address is 0x19 . The accel values: x = 122 , y = 761 , z = 376 x = 122 , y = 761 , z = 376 x = 122 , y = 761 , z = 376 x = 125 , y = 680 , z = 470 x = 125 , y = 680 , z = 470 x = 163 , y = 664 , z = 708 x = 163 , y = 664 , z = 708 x = 102 , y = 657 , z = 931 x = 102 , y = 657 , z = 931 x = 102 , y = 657 , z = 931

End of LPI2C example.

FRDM-KW43
Hardware requirements
  • Type-C USB cable

  • FRDM-KW43 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 J28.

  2. Open a serial terminal on PC for the serial device with these 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.

LPI2C example – Read Accelerometer Value Found an FXLS8964 on board , the device address is 0x19 . The accel values: x = 3 , y = 0 , z = 1098 x = 3 , y = 0 , z = 1098 x = 0 , y = -28 , z = 1108 x = 0 , y = -28 , z = 1108 x = 0 , y = -28 , z = 1108 x = 0 , y = -16 , z = 1107 x = 0 , y = -16 , z = 1107 x = 4 , y = -32 , z = 1088 x = 4 , y = -32 , z = 1088 x = 16 , y = -24 , z = 1091

End of LPI2C example.

FRDM-MCXW70
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXW70 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 J28.

  2. Open a serial terminal on PC for the serial device with these 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.

LPI2C example – Read Accelerometer Value Found an FXLS8964 on board , the device address is 0x19 . The accel values: x = 3 , y = 0 , z = 1098 x = 3 , y = 0 , z = 1098 x = 0 , y = -28 , z = 1108 x = 0 , y = -28 , z = 1108 x = 0 , y = -28 , z = 1108 x = 0 , y = -16 , z = 1107 x = 0 , y = -16 , z = 1107 x = 4 , y = -32 , z = 1088 x = 4 , y = -32 , z = 1088 x = 16 , y = -24 , z = 1091

End of LPI2C example.