Jump to content
  • 0

Commnication between ADXL345 accelerometer and UNO32


michastro

Question

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:

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 :-(

Any idea?

 

Thanks a lot

Michel

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hello,

I think that the best place to start is to take a look on the PmodACL http://www.digilentinc.com/Products/Detail.cfm?Prod=PMOD-ACL device. It is based on the same device ADXL345 and we provide a MPIDE library for it http://www.digilentinc.com/Data/Products/PMOD-ACL/PmodACL-MPIDE-libs.zip.

Then, you will notice that we are using DSPI library, in DSPI_MODE3. Why don't you use DSPI ? It is the Digilent SPI library and it's working very nice. Of course you can still use the SPI library.

Regardles of the DSPI or SPI usage, you should properly set the UNO32 for SPI.

By reading the reference manual http://www.digilentinc.com/Data/Products/CHIPKIT-UNO32/chipKIT_Uno32_RM.pdf you will find that JP4  is used to switch connector J5 pin 5 (digital signal 10) between pulse width modulator (PWM) operation and SPI operation. Also, JP5 and JP7 can affect SPI, so please read on page 9, chapter "3.5 Peripheral I/O Functions" more about SPI.

Please write me if you have further questions.

Regards,

Cristian

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...