AnsweredAssumed Answered

Question about reading adxl345

Question asked by jacruz on Jun 5, 2014
Latest reply on Jun 18, 2014 by neilzhao

Hi,

 

I'm reading the register 0x00 (DEVID) of the adxl345 sensor and I've a problem. Most of times it works well and i get 0xE5, but sometimes it returns 0xCB.

 

Please, can you tell me what I'm doing wrong?

 

I'm using PIC18F26K22 as microcontroller and the code that I'm using to read it, it's as follows:

 

setup_spi(SPI_MASTER |  SPI_H_TO_L |  SPI_CLK_DIV_4 | SPI_XMIT_L_TO_H | SPI_SAMPLE_AT_END);

...

    output_low(PIN_CS);
    spi_write(0x00);
    int8 dato = spi_read(0x00);
    output_high(PIN_CS);

Outcomes