Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

DE1-SoC Interfacing with ADXL345 3 Axis Accelerometer [I2C]

Honored Contributor II

I have a DE1-SoC board and I'm using the low level altera provided API calls included with the board. I have also referenced the article published "Using the Accelerometer on DE-SoC Boards" which provides for high level routines. I've pretty much mapped out all the instances of the high level code to the low level api calls, and I'm having trouble with the I2C module not sending the data. Interupts disabled, took the module out of reset, correctly set up the configuration of the I2C module, and it's atually talking to the ADXL sensor but it's doing it the wrong way. When I fill the tx fifo with entries to read the chip ID, it takes 64 calls to the buffer before it will even send the data. On the 65th call, I actually read the ID provided on the ADXL. I setup a STOP bit after the data so the FIFO won't empty and stall the SCL line. I'm not referencing any DMA control because I can't even get the tx buffers to send the data. I'm not sure what the problem is?  

I strongly feel I'm stuck on the read register routine provided in the article, and the author is referencing using a Restart bit to initiate the transfer, however the HPS manual says by putting data on the cmd register, it initiates the transfer.
0 Kudos
1 Reply
Honored Contributor II



When sending over the I2C the first byte has to have the restart bit set and the last byte has to have the stop condition bit set. 

When it's a single byte, both bits must be set. 


e.g, sending bytes (0x11, 0x22, and 0x33) these are written to the data-command register: 

*Reg = 0x11 | (1<<10); 

*Reg = 0x22; 

*Reg = 0x33 | (1<< 9); 


When sending one byte (0x11): 

*Reg = 0x11 | (1<<9) | (1<<10) 


0 Kudos