Hello everyone!
Problem: On my board, the
ISM330DLC accelerometer is integrated with
LPC824 microcontroller via SPI interface.
However, at the software level, I encountered problems reading/writing the accelerometer registers. Initially, I simply decided to read data from the
WHO_AM_I register, but the data I receive in response does not match what is described in the accelerometer's datasheet. That is,
WHO_AM_I should return
0x6A, but it returns
0x88.
A detailed example of my problem: I write two bytes of information to
txBuffer: [0x8F, 0x00]. In binary,
txBuffer = 10001111 00000000. According to the accelerometer datasheet, the 0th bit is R\W - 0 for write, 1 for read. The next 7 bits are the register address for the operation. Bits 8-15 are for writing; I assume they're ignored during reading. So, the command [0x8F, 0x00] requests a read from the WHO_AM_I register.
However,
I get an rxBuffer output of [0xFF, 0x88], which is not what I expected. Also, why is the first byte always 0xFF whenever I try to read any register?
Accelerometer has a register that allows configuring access to other registers, as strange as that might sound (see the first screenshot). In this way, if I don't set the required flag to 1, any read request returns
[0xFF, 0x00]. From this, I concluded that writing data works, but reading doesn't. However, I might be wrong, as this is my first experience in embedded development
Code:To work on the microcontroller, I used the functionality of
MCUXpresso SDK.
Link to
main.c:
https://github.com/teleportboy/lpc824_spi/blob/4c3f20cbc3018be76f213c5112d54ef2cd48b409/source/main.c#L24Link to init pins:
https://github.com/teleportboy/lpc824_spi/blob/4c3f20cbc3018be76f213c5112d54ef2cd48b409/board/pin_mux.c#L72Link to project:
https://github.com/teleportboy/lpc824_spiI would greatly appreciate any advice.