SPI Communication with an external ADC and SD card

I am a newbie to the world of Arduino, so excuse me for this very basic question.

I am trying to communicate with an external ADC (ADS124S08) and SD card using Arduino UNO. The goal is to read from an analog sensor using the ADC and store data to the SD card. I have connected the ADC, datalogger and the sensor to arduino and reading from the ADC and writing to the SD card works separately without any issue.

I connected MISO, MOSI and SCLK of arduino to the corrosponding pins of SD card and ADC, only the chip select pin different for both the devices (Pin 4 for ADC, 10 for SD card). Please see the sketch in the attachment.

Inside the loop function, if I comment out the 3rd line, which calls the sd card setup- the ADC works fine. But when that function is active, the ADC doesn't work. I am thinking somehow I am messing up while trying to switch the chip select pins. Any help will be appreciated.

ADCONECHANNEL.ino (3.3 KB)

The good news is that you're using the SPI.beginTransaction() call to set the correct SPI parameters. But I'm missing the corresponding endTransaction() call. Additionally you're doing the transaction stuff only in the setup() but not in the loop(). That call is necessary for every transaction.
The SD card library is handling it's CS pin itself, so you don't have to do that.
As the SD card is running SPI mode 0 the transaction handling is necessary to allow your ADC to work.

Thank you very much pylon. SPI.beginTransaction() was stated only in the setup function, not in in the main loop. I put it in the main loop, now everything works