Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 5 months ago.
How to realize communication between MSP430F5438A and ADXL345
Hi!
/media/uploads/roc_Sa/10.5.2013_acc_spi_code_15.28.txt Thanks for the hints and the critic. I found the Basic example Code from Sparkfun and I am trying to adjust the Code for my MSP430, but I have
got some problems. I defined the Buffer, but I am getting confused with the data of 10 bits from the accelerator.
I added a line for every value in the Interruptroutine. Please check this.
This buffer will hold values read from the ADXL345 registers.
char values[10];
These variables will be used to hold the x,y and z axis accelerometer values.
int x,y,z;
(Copied from the Basis Code)
I do not how I can built the stuff down below into my code. Can you give me some help?
The ADXL345 gives 10-bit acceleration values, but they are stored as bytes (8-bits). To get the full value, two bytes must be combined for each axis.
The X value is stored in values[0] and values[1].
x = ((int)values[1]<<8)|(int)values[0];
The Y value is stored in values[2] and values[3].
y = ((int)values[3]<<8)|(int)values[2];
The Z value is stored in values[4] and values[5].
z = ((int)values[5]<<8)|(int)values[4];
I want to know how to implement the shift operations and afterwards the reading operation for my MSP430 in my existing code. Can I put the
shift operation in the interrupt routine?
Thanks and greetings