FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5930 Discussions

I2C read of De0 nano accelerometer

Altera_Forum
Honored Contributor II
3,511 Views

Hello everyone, 

I am using de0 nano and would like to try I2C read of accelerometer(ADXL345) that embedded in de0 nano. 

So I take it that I2C read has the following sequence: 

1) generate start signal 

2) write slave address(0011101) + write bit(0) 

3) receive acknowledge from slave 

4) write memory location(register with add 00110000 has reset value of 00000010) 

5) receive acknowledge from slave 

6) generate repeated start signal 

7) write slave address + read bit(1) 

8) receive acknowledge from slave 

9) read byte from slave 

10) write no acknowledge (NACK) to slave, indicating end of transfer 

11) generate stop signal 

 

Everything's going fine until step 9.The value ,that was read at step 9, is 11111111. 

I expect the data value to be 00000010 because it is the reset value of register 00110000. 

I generate clock of 100 hz for the whole operation because the default/reset value of register BW_Rate is 00001010 (this register control the "output data rate") which translate that output data rate is 100hz.  

Could someone give me an advice to be able to read the correct data? 

Your help is fully appreciated.
0 Kudos
21 Replies
Altera_Forum
Honored Contributor II
141 Views

Hello sindredit, 

 

well, as you can see at the title, the purpose is to read the data value of registers inside the ADXL345 (accelerometer) using I2C protocol. 

The problem I encountered were (therefore I asked this question in this thread) 

1. I was new in FPGA and not familiar with I2C communication protocol 

2. I was not able to find the "right" timing diagram to communicate with the ADXL 

 

Now by reading this thread, you could just use the I2C timing diagram. 

It should be noted that it is all about I2C read and write to interface with the ADXL. 

I recommend you to start by learning the I2C protocol before starting with the ADXL interfacing. 

 

Cheers, 

 

Gunardilin
0 Kudos
Reply