SPI interfering with digitalRead

I’m working on a project that utilizes an external 24Bit ADC on the SPI bus and 3 pushbuttons intended for menu options. Everything works independently, but there’s a significant button response delay when all component functions are combined into one program. From what I gather, since I’m using a delay(); for the SPI, the program stops for a specified amount of time. In that delay window, the processor does not see that I’ve just pushed a button. I would certainly like to use the SPI without using a delay(). Anyone know how to do that? Is it even possible? Here’s my code for the SPI:

 void loop() {
    int i;
    long secs;
    float mins;
    long analogValue;
    long in;         // incoming serial 32-bit word
    long sum = 0;

        for (i=0; i<nsamples; i++) {
          in = SpiRead();
          in &= 0x1FFFFFFF; // force high three bits to zero
          in = in>>5;   // truncate lowest 5 bits
          sum += in;
          delay(198);      // (msec). Total Looptime: +2 msec (overhead for comms)
        }
}

long SpiRead(void) {

      long result = 0;
      long b;
     
    //long result2 = 0;// MOSI/SDI pin 7 HIGH => 7 Hz, best resolution

      digitalWrite(slaveSelectPin,LOW);   // take the SS pin low to select the chip
      delayMicroseconds(1);              // probably not needed, only need 25 nsec delay
     
      b = SPI.transfer(0xff);   // B3
      result = b<<8;
      b = SPI.transfer(0xff);   // B2
      result |= b;
      result = result<<8;
      b = SPI.transfer(0xff);   // B1
      result |= b;
      result = result<<8;
      b = SPI.transfer(0xff);   // B0
      result |= b;
     
      // take the SS pin high to de-select the chip:
      digitalWrite(slaveSelectPin,HIGH);
      return(result);
    }

Thanks for the guidance.

I would certainly like to use the SPI without using a delay().

So, why do you have the delay() in there?

The ADC that I'm using is an LTC2440. In the datasheet, it specifies that the Chip Select pin must go LOW for about 198 mSec for packet transfer. So I added delay(198); in the code and it works great. Unfortunately, the menu pushbuttons don't work during that packet transfer time period.

Here's a link to the ADC datasheet:

http://cds.linear.com/docs/en/datasheet/2440fd.pdf

198 mS or micro sceonds? 198 ms is almost .2 seconds! And if you really need that amount of time look into the BlinkWithoutDelay example and use millis() to delay without blocking.

Oh man, it just clicked. Thanks for pointing me in the right direction. I think I've got it figured out.