I'd like to connect the ADXL345 sensor and SD card into the Mega 2560. Each card works ok. individually. They use these SPI pins:
pin 50 ----> SDO (MISO)
pin 51 ----> SDA (MOSI)
pin 52 ----> SCL (SCK)
pin 53 ----> SS (CS)
I understand that the SPI can work as master and slave and can share these pins except pin 53, one has to be assigned into different pin. I tried pin 10 without success.
How should I connect them together ?
Also keep in mind that both devices require 3.3V interfaces, while the Mega is 5V, so level shifting will be required. SD card will also need a 3.3V supply, I don't believe the regulator on the Mega can put out enough current.
You are connecting them correctly - both get SCK, MISO, and MOSI in parallel.
Each needs its own Chip Select - only one CS can be low at a time while transfers are occurring with that device.
You are right. I turned both devices HIGH that caused the problem. It is working now.
Does it mean that if I have several SPI devices connect in parallel, only 1 SPI device be activated at a time ?
Many thanks for your advise.
@SurferTim : thanks a lot for your info. It is really big help. @CrossRoads: thanks for your advise. I haven't checked the accuracy of the data of the sensor but it seems to be in the range it should be. When I turned high both devices, the sensor produced very high numbers (out of range).