Other Parts Discussed in Thread: MSP430F5638, MSP430F2274
Everyone,
I have a MSP430F5638 that is interfacing with an ADXL345 accelerometer over SPI. I am attempting to write the values of X, Y, and Z into a buffer. Note that each axis is one word long and requires concatenation of the first byte sent (LSB) and the second byte sent (MSB). The X axis is read first followed by Y then Z for a total of 6 registers read on the accelerometer.
My problem is in recovering the proper values of X, Y, and Z during a multi-register read. When stepping through the code below in debug, I get the proper values. I am also able to view any register on the ADXL, so the SPI communication is not an issue. However, when I set a break point at "SPI_OFF" the X-axis value is stored in the Y slot in the buffer and Y-axis value is stored in the Z slot in the buffer. The Z data is lost completely. Visually:
X -> Y
Y->Z
Z->0x00
Where the variable on the left is the axis being observed and the right variable is the position in the buffer. I have attempted to correct the issue by disabling interrupts, but that did not work. I then tried adding delays after the write, that too did not work. It seems like this is a timing issue, but I do not see in the datasheet for the ADXL345 any timing issues that would be a problem. I realize this is a TI MSP forum, but I am not sure where to get help. Any suggestions are appreciated!