Problem to receive data from ADXL345 and to store it to SD Card

Hi,

I need some help to make an Arduino project for my studies. I am using arduino nano v3.0. I am trying to connect a SD card and 3 accelerometer (ADXL345) to the Arduino SPI port.

First I sucess to make 2 projects. One, using one accelerometer only and recieving data with SPI bus. Second, storing random values to SD card using SD library.

Now I am trying to connect the twice (1 accelerometer and SD card). I have few problems :
• In setup part of Arduino program, if I configure accelerometer first (Configure SPI bus for adxl345) and after the SD card (with SD.h library) I will not receive values by accelerometer.
• If I configure SD card first, I recieve some data but the SPI clock will stop before end of communication.

This is my code:

Acc_SD_card.c (5.14 KB)