I have built an application to interface an accelerometer with the new LPC845 Breakout board using the I2C SDK driver.
The accelerometer acts as an I2C slave device to the LPC845 master device. Colors on the on-board RGB LED change according to the accelerometer position.
The accelerometer is a slave device in this application with slave address: 0x1D. The position of the board is determined by the x,y,z-axis values obtained from this slave device. The change in these x,y,z values detects the movement of the LPC845 Breakout board. I have assigned various patterns to the RGB LEDs for each movement along the y-axis.
Refer to the table for the hardware Connections for this application: The NXP MMA8652 3-axis accelerometer on the breakout board can be connected usingI2C protocol.SCL, SDA lines and can be powered via VDD, VDDIO and GND pins.
Connect pins of I2C master and slave as below:
The LPC845 Breakout board has an SDK package support. I used the I2C SDK driver API in the software for interfacing the hardware components. The MCUXpresso SDK Builderhas open source drivers, middleware, and reference example applications for software development. Customize and download the SDK specific to the processor and thenimport the zip fileto the project in MCUXpresso IDE.
The LPC845 Breakout board also features function-configurable I/O ports through a switch matrix (SWM). This makes it easier to configure pin routing and other pin electrical features. The configuration tool which is integrated into the IDE is useful for making changes in the switch matrix. The source code is auto-generated when the pin configuration or peripherals are changed.
/* I2C0_SDA connect to P0_11 */ SWM_SetFixedPinSelect(SWM0, kSWM_I2C0_SDA, true);
/* I2C0_SCL connect to P0_10 */ SWM_SetFixedPinSelect(SWM0, kSWM_I2C0_SCL, true);
The source code for this application and board info for the LPC845 Breakout board can be found here.