I try to communicate between UNO32 and ADXL345 accelerometer via SPI.After a lot of tries, I allways received 0xFF when I read adress 0x00, but I should received the ID of ADXL345 board=0x5A. The ADXL is connected like that:
* CS - to digital pin 10 (SS pin) * SDI - to digital pin 11 (MOSI pin) * SDO - to digital pin 12 (MISO pin) * CLK - to digital pin 13 (SCK pin)
and my setup is:
Serial.begin(9600);
// set the slaveSelectPin as an output:
pinMode (chipSelectPin, OUTPUT);
// initialize SPI:
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV32 );
SPI.setDataMode(SPI_MODE0) ;
SPI.setBitOrder(MSBFIRST);
digitalWrite(chipSelectPin, LOW);
// send in the address and value via SPI:
value=SPI.transfer(0x00);
digitalWrite(chipSelectPin, HIGH);
Serial.print("ID=");
Serial.println(value,HEX);
I have tried different SPI_MODE, nothing to do :-(
Question
michastro
Hello,
I try to communicate between UNO32 and ADXL345 accelerometer via SPI.After a lot of tries, I allways received 0xFF when I read adress 0x00, but I should received the ID of ADXL345 board=0x5A. The ADXL is connected like that:
* CS - to digital pin 10 (SS pin)
* SDI - to digital pin 11 (MOSI pin)
* SDO - to digital pin 12 (MISO pin)
* CLK - to digital pin 13 (SCK pin)
and my setup is:
I have tried different SPI_MODE, nothing to do :-(
Any idea?
Thanks a lot
Michel
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.