MCUXpresso SDK Documentation

lpi2c_read_accel_value_transfer

lpi2c_read_accel_value_transfer#

Overview#

The lpi2c_read_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#

EVK9-MIMX8ULP
Hardware requirements
  • Micro USB cable

  • MIMX8ULP-EVK/EVK9 board

  • J-Link Debug Probe

  • 5V power supply

  • Personal Computer

Board settings

No special settings are required.

Please note this application can’t support running with Linux BSP!

Prepare the Demo
  1. Connect 5V power supply and J-Link Debug Probe to the board, switch SW10 to power on the board.

  2. Connect a micro USB cable between the host PC and the J17 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

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

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 FXOS8700 on board , the device address is 0x1e .
The accel values:
status_reg = 0x5 , x = 17156 , y = 22528 , z = -17600
status_reg = 0x5 , x = 16132 , y = 21760 , z = -17344
status_reg = 0x5 , x = 15108 , y = 21760 , z = -17344
status_reg = 0x5 , x = 16132 , y = 22272 , z = -18368
status_reg = 0x5 , x = 16132 , y = 23040 , z = -17344
status_reg = 0x5 , x = 16644 , y = 22272 , z = -16320
status_reg = 0x5 , x = 15364 , y = 23040 , z = -16576
status_reg = 0x5 , x = 16388 , y = 22528 , z = -17344
status_reg = 0x5 , x = 17412 , y = 21760 , z = -16832
status_reg = 0x5 , x = 16644 , y = 23296 , z = -15808

End of LPI2C example .
EVK-MCIMX7ULP
Hardware requirements
  • Micro USB cable

  • MCIMX7ULP-EVK board

  • J-Link Debug Probe

  • 5V power supply

  • Personal Computer

Board settings

No special settings are required.

Please note this application can’t support running with Linux BSP!

Prepare the Demo
  1. Connect 5V power supply and J-Link Debug Probe to the board, switch SW1 to power on the board.

  2. Connect a micro USB cable between the host PC and the J6 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

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

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 FXOS8700 on board , the device address is 0x1e .
The accel values:
status_reg = 0xff , x =   101 , y =    48 , z =  2123
status_reg = 0xff , x =   101 , y =    45 , z =  2123
status_reg = 0xff , x =   101 , y =    48 , z =  2129
status_reg = 0xff , x =   102 , y =    50 , z =  2120
status_reg = 0xff , x =    99 , y =    50 , z =  2123
status_reg = 0xff , x =    99 , y =    47 , z =  2127
status_reg = 0xff , x =    99 , y =    49 , z =  2133
status_reg = 0xff , x =    99 , y =    48 , z =  2128
status_reg = 0xff , x =   101 , y =    46 , z =  2129
status_reg = 0xff , x =   100 , y =    47 , z =  2111

End of LPI2C example .
EVK-MIMX8ULP
Hardware requirements
  • Micro USB cable

  • MIMX8ULP-EVK/EVK9 board

  • J-Link Debug Probe

  • 5V power supply

  • Personal Computer

Board settings

No special settings are required.

Please note this application can’t support running with Linux BSP!

Prepare the Demo
  1. Connect 5V power supply and J-Link Debug Probe to the board, switch SW10 to power on the board.

  2. Connect a micro USB cable between the host PC and the J17 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

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

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 FXOS8700 on board , the device address is 0x1e .
The accel values:
status_reg = 0x5 , x = 17156 , y = 22528 , z = -17600
status_reg = 0x5 , x = 16132 , y = 21760 , z = -17344
status_reg = 0x5 , x = 15108 , y = 21760 , z = -17344
status_reg = 0x5 , x = 16132 , y = 22272 , z = -18368
status_reg = 0x5 , x = 16132 , y = 23040 , z = -17344
status_reg = 0x5 , x = 16644 , y = 22272 , z = -16320
status_reg = 0x5 , x = 15364 , y = 23040 , z = -16576
status_reg = 0x5 , x = 16388 , y = 22528 , z = -17344
status_reg = 0x5 , x = 17412 , y = 21760 , z = -16832
status_reg = 0x5 , x = 16644 , y = 23296 , z = -15808

End of LPI2C example .
FRDM-K32L2A4S
Hardware requirements
  • Mini/Micro USB cable

  • FRDM-K32L2A4S 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.

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 a FXOS8700 on board , the device address is 0x1e .

The accel values:

status_reg = 0xff , x =    24 , y =   -66 , z =  2119
status_reg = 0xff , x =    24 , y =   -65 , z =  2120
status_reg = 0xff , x =    27 , y =   -68 , z =  2112
status_reg = 0xff , x =    29 , y =   -64 , z =  2114
status_reg = 0xff , x =    21 , y =   -66 , z =  2114
status_reg = 0xff , x =    31 , y =   -69 , z =  2124
status_reg = 0xff , x =    28 , y =   -65 , z =  2117
status_reg = 0xff , x =    28 , y =   -67 , z =  2115
status_reg = 0xff , x =    24 , y =   -64 , z =  2114
status_reg = 0xff , x =    28 , y =   -73 , z =  2115

End of LPI2C example .
FRDM-K32L3A6
Hardware requirements
  • Mini/Micro USB cable

  • FRDM-K32L3A6 board

  • Personal Computer

Board settings

Please ensure there is FXOS8700 on board

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.

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 a FXOS8700 on board , the device address is 0x1e .

The accel values:

status_reg = 0xff , x =    24 , y =   -66 , z =  2119
status_reg = 0xff , x =    24 , y =   -65 , z =  2120
status_reg = 0xff , x =    27 , y =   -68 , z =  2112
status_reg = 0xff , x =    29 , y =   -64 , z =  2114
status_reg = 0xff , x =    21 , y =   -66 , z =  2114
status_reg = 0xff , x =    31 , y =   -69 , z =  2124
status_reg = 0xff , x =    28 , y =   -65 , z =  2117
status_reg = 0xff , x =    28 , y =   -67 , z =  2115
status_reg = 0xff , x =    24 , y =   -64 , z =  2114
status_reg = 0xff , x =    28 , y =   -73 , z =  2115

End of LPI2C example .
FRDM-KE15Z
Hardware requirements
  • Micro USB cable

  • FRDM-KE15Z board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a USB cable between the host PC and the OpenSDA 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.

Running the demo

When the example runs successfully, the following message is displayed in the terminal:

LPI2C example -- Read Accelerometer Value

Found a FXOS8700 on board , the device address is 0x1C .

The accel values:

status_reg = 0xff , x =    60 , y =   -80 , z =  2094

status_reg = 0xff , x =    54 , y =   -73 , z =  2088

status_reg = 0xff , x =    54 , y =   -77 , z =  2096

status_reg = 0xff , x =    57 , y =   -79 , z =  2096

status_reg = 0xff , x =    57 , y =   -83 , z =  2089

status_reg = 0xff , x =    55 , y =   -78 , z =  2102

status_reg = 0xff , x =    56 , y =   -77 , z =  2097

status_reg = 0xff , x =    57 , y =   -77 , z =  2085

status_reg = 0xff , x =    59 , y =   -78 , z =  2094

status_reg = 0xff , x =    56 , y =   -79 , z =  2093

End of LPI2C example .
FRDM-KE16Z
Hardware requirements
  • Micro USB cable

  • FRDM-KE16Z board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a USB cable between the host PC and the OpenSDA 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.

Running the demo

When the example runs successfully, the following message is displayed in the terminal:

LPI2C example -- Read Accelerometer Value

Found a FXOS8700 on board , the device address is 0x1C .

The accel values:

status_reg = 0xff , x =    60 , y =   -80 , z =  2094

status_reg = 0xff , x =    54 , y =   -73 , z =  2088

status_reg = 0xff , x =    54 , y =   -77 , z =  2096

status_reg = 0xff , x =    57 , y =   -79 , z =  2096

status_reg = 0xff , x =    57 , y =   -83 , z =  2089

status_reg = 0xff , x =    55 , y =   -78 , z =  2102

status_reg = 0xff , x =    56 , y =   -77 , z =  2097

status_reg = 0xff , x =    57 , y =   -77 , z =  2085

status_reg = 0xff , x =    59 , y =   -78 , z =  2094

status_reg = 0xff , x =    56 , y =   -79 , z =  2093

End of LPI2C example .
FRDM-KE17Z
Hardware requirements
  • Micro USB cable

  • FRDM-KE17Z board

  • Personal Computer

Board settings

Make sure the FXOS8700CQ(U12) on the board is installed to run this demo. No special settings are required.

Prepare the Demo
  1. Connect a USB cable between the host PC and the OpenSDA 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.

Running the demo

When the example runs successfully, the following message is displayed in the terminal:

LPI2C example -- Read Accelerometer Value

Found a FXOS8700 on board , the device address is 0x1C .

The accel values:

status_reg = 0xff , x =    60 , y =   -80 , z =  2094

status_reg = 0xff , x =    54 , y =   -73 , z =  2088

status_reg = 0xff , x =    54 , y =   -77 , z =  2096

status_reg = 0xff , x =    57 , y =   -79 , z =  2096

status_reg = 0xff , x =    57 , y =   -83 , z =  2089

status_reg = 0xff , x =    55 , y =   -78 , z =  2102

status_reg = 0xff , x =    56 , y =   -77 , z =  2097

status_reg = 0xff , x =    57 , y =   -77 , z =  2085

status_reg = 0xff , x =    59 , y =   -78 , z =  2094

status_reg = 0xff , x =    56 , y =   -79 , z =  2093

End of LPI2C example .
MCIMX93AUTO-EVK
Hardware requirements
  • USB Type-C cable

  • MCIMX93AUTO-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

Board settings

No special settings are required.

Note

Please run the application in Low Power boot mode (without Linux BSP). The IP module resource of the application is also used by Linux BSP. Or, run with Single Boot mode by changing Linux BSP to avoid resource conflict.

Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW2 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J26 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

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 LSM6DSO on board , the device address is 0x6A.
The accel values:
status_reg = 0x5 , x = 17156 , y = 22528 , z = -17600
status_reg = 0x5 , x = 16132 , y = 21760 , z = -17344
status_reg = 0x5 , x = 15108 , y = 21760 , z = -17344
status_reg = 0x5 , x = 16132 , y = 22272 , z = -18368
status_reg = 0x5 , x = 16132 , y = 23040 , z = -17344
status_reg = 0x5 , x = 16644 , y = 22272 , z = -16320
status_reg = 0x5 , x = 15364 , y = 23040 , z = -16576
status_reg = 0x5 , x = 16388 , y = 22528 , z = -17344
status_reg = 0x5 , x = 17412 , y = 21760 , z = -16832
status_reg = 0x5 , x = 16644 , y = 23296 , z = -15808

End of LPI2C example .
MCIMX93-EVK
Hardware requirements
  • USB Type-C cable

  • MCIMX93-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

Board settings

No special settings are required.

Note

Please run the application in Low Power boot mode (without Linux BSP). The IP module resource of the application is also used by Linux BSP. Or, run with Single Boot mode by changing Linux BSP to avoid resource conflict.

Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

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 LSM6DSO on board , the device address is 0x6A.
The accel values:
status_reg = 0x5 , x = 17156 , y = 22528 , z = -17600
status_reg = 0x5 , x = 16132 , y = 21760 , z = -17344
status_reg = 0x5 , x = 15108 , y = 21760 , z = -17344
status_reg = 0x5 , x = 16132 , y = 22272 , z = -18368
status_reg = 0x5 , x = 16132 , y = 23040 , z = -17344
status_reg = 0x5 , x = 16644 , y = 22272 , z = -16320
status_reg = 0x5 , x = 15364 , y = 23040 , z = -16576
status_reg = 0x5 , x = 16388 , y = 22528 , z = -17344
status_reg = 0x5 , x = 17412 , y = 21760 , z = -16832
status_reg = 0x5 , x = 16644 , y = 23296 , z = -15808

End of LPI2C example .
MCIMX93W-EVK
Hardware requirements
  • USB Type-C cable

  • MCIMX93W-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

Board settings

No special settings are required.

Note

Please run the application in Low Power boot mode (without Linux BSP). The IP module resource of the application is also used by Linux BSP. Or, run with Single Boot mode by changing Linux BSP to avoid resource conflict.

Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

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 LSM6DSO on board , the device address is 0x6A.
The accel values:
status_reg = 0x5 , x = 17156 , y = 22528 , z = -17600
status_reg = 0x5 , x = 16132 , y = 21760 , z = -17344
status_reg = 0x5 , x = 15108 , y = 21760 , z = -17344
status_reg = 0x5 , x = 16132 , y = 22272 , z = -18368
status_reg = 0x5 , x = 16132 , y = 23040 , z = -17344
status_reg = 0x5 , x = 16644 , y = 22272 , z = -16320
status_reg = 0x5 , x = 15364 , y = 23040 , z = -16576
status_reg = 0x5 , x = 16388 , y = 22528 , z = -17344
status_reg = 0x5 , x = 17412 , y = 21760 , z = -16832
status_reg = 0x5 , x = 16644 , y = 23296 , z = -15808

End of LPI2C example .
MCIMX93-QSB
Hardware requirements
  • USB Type-C cable

  • MCIMX93-QSB board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

Board settings

No special settings are required.

Note

Please run the application in Low Power boot mode (without Linux BSP). The IP module resource of the application is also used by Linux BSP. Or, run with Single Boot mode by changing Linux BSP to avoid resource conflict.

Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

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 LSM6DSO on board , the device address is 0x6A.
The accel values:
status_reg = 0x5 , x = 17156 , y = 22528 , z = -17600
status_reg = 0x5 , x = 16132 , y = 21760 , z = -17344
status_reg = 0x5 , x = 15108 , y = 21760 , z = -17344
status_reg = 0x5 , x = 16132 , y = 22272 , z = -18368
status_reg = 0x5 , x = 16132 , y = 23040 , z = -17344
status_reg = 0x5 , x = 16644 , y = 22272 , z = -16320
status_reg = 0x5 , x = 15364 , y = 23040 , z = -16576
status_reg = 0x5 , x = 16388 , y = 22528 , z = -17344
status_reg = 0x5 , x = 17412 , y = 21760 , z = -16832
status_reg = 0x5 , x = 16644 , y = 23296 , z = -15808

End of LPI2C example .