I need to talk to the SPU6500 in SPI protocol since I already use that to talk with the SD card.
Ok, cool. For now, use I2C and the Wire.h library to update the register contents and then use SPI to read the data registers. Know what I mean?
There is a way to doing it with the library SPI.h, but I’ve never used SPI on Arduinos (used it on a PIC32 once, though ).
IMPORTANT: You will also need to “wake up” the accelerometer by updating the power management register in the same manner as the registers this post is about. You can read about it in the datasheet.
4 first bits 0000
is the value I need to use is 000000011 ??
Close, but no, A_DLPF_CFG is only 3 bits wide. Your final value has to be 8 bits, since all registers are 8 bits wide.
Your REAL value: 00000011
I have seen this phrase used
"#define ACCEL_CONFIG_2 0x1D "
But how do place the value into the ACCEL_CONFIG_2 ?
The #define phrase makes a permanent variable named “ACCEL_CONFIG_2” with a read only value of 0x1D. This allows you to use the register name “ACCEL_CONFIG_2” instead of having to use the actual address (0xD1). In short, it makes your code easier to understand.
How you do it in I2C with the Wire.h library:
#define MPU6500_ADDRESS (insert I2C device address here)
#define ACCEL_CONFIG_2 0x1D
Wire.write(0x3); //00000011 = 0x3 (binary to hex)