I2C interface to ADXL345 Accelerometer?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Anyone have any example code for interfacing a 5LP to an Analog Devices ADXL3xx accelerometer using i2c?

   

Im interested in the best way of implementing the write/read operations in which you write a register number and read the content.

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I used a different accellerometer with I2C and it resulted in the sequence of

   

I2C_SendStart()

   

I2C_WriteByte()

   

I2C_SendRestart()

   

I2C_ReadByte(NAK)

   

My device allowed for multiple reads which were done with I2C_ReadByte(ACK) while only the last byte was red with a NAK.

   

Never forget to analyze a returned state for error conditions.

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Oh, yes, and of course a I2C_SendStop().

   

 

   

Bob

0 Likes