Forum Discussion
Altera_Forum
Honored Contributor
13 years agoDE0-nano's adxl345 accelerometer via SPI-3 wire
Hello, Recently I started a project in wich I have to get the datas from the 3 axis of the accelerometer ADXL345 of the DE0-nano board. I only have some skills in VHDL but i can understand ve...
Altera_Forum
Honored Contributor
13 years ago --- Quote Start --- .... I don't know if you code does it, but before the SPI-3 (SPI-4 on DE0-nano is impossible) you must change a register value, because the default communication SPI is 4, as you don't have 4 pins, you must communicate through I2C, reconfigure the register, so the SPI-4 become SPI-3. --- Quote End --- No, this should not be necessary. If you look at the SPI-3 vs SPI-4 protocol, the Write would be the same so you should be able to configure 0x31 to 3-wire SPI via SPI and then do all your reads in 3-wire mode. The only trick is that there is another I2C device on the same bus on the DE0 Nano board, so you must structure your SPI communications so that you do not trigger an I2C Start or Stop frame. I have done this and can successfully read the DEVID register via SPI. I am not familiar with Verilog, so I don't know if all Verilog is like the sample or they are just particular bad coders, but I couldn't really follow the sample either, so I wrote my own version from scratch in VHDL. I have generic modules to read/write via SPI so it now should be a relatively short matter to configure all the registers I need to read all 3-axis and grab the data.