does spi communication disable interrupt?

i am using rotary encoder , sd and ps2 controller.

as spi communication disables interrupts several times does this will effect my encoder reading.?

varangupta: as spi communication disables interrupts several times

What makes you say that? If you're using the SPI library, it doesn't disable interrupts, see SPI.h and SPI.cpp

varangupta:
i am using rotary encoder , sd and ps2 controller.

as spi communication disables interrupts several times does this will effect my encoder reading.?

Not enough information. For instance where is the code that’s doing this?

Why would you disable interrupts to read SPI anyway?

unsigned char PS2X::_gamepad_shiftinout (char byte) {
   uint8_t old_sreg = SREG;        // *** KJE *** save away the current state of interrupts
  

   unsigned char tmp = 0;
   cli();                          // *** KJE *** disable for now
   for(i=0;i<8;i++) {

	  if(CHK(byte,i)) SET(*_cmd_oreg,_cmd_mask);  //this sets cmd bit by bit according to value in byte
	  else  CLR(*_cmd_oreg,_cmd_mask);
	  CLR(*_clk_oreg,_clk_mask);                  //clk is pulled low before recieving the data

      SREG = old_sreg;  // *** *** KJE *** *** Interrupts may be enabled again 
	  delayMicroseconds(CTRL_CLK);
	  cli();	// *** KJE ***

	  if(CHK(*_dat_ireg,_dat_mask)) SET(tmp,i); //this check the recieved data bit by bit and store is to temp
	  SET(*_clk_oreg,_clk_mask);                //after recieving clk is pulled up
   }
   SET(*_cmd_oreg,_cmd_mask);
   SREG = old_sreg;  // *** *** KJE *** *** Interrupts may be enabled again 
   delayMicroseconds(CTRL_BYTE_DELAY);
   return tmp;
}

cli(); is used several times

PS2X_lib.cpp (23.6 KB)

Well I see no reason for it, SPI is not a synchronous protocol.

Same issue here. I am using an arduino Pro Micro and interrupt 0 on pin 3. If I don’t use SPI the interrupt works fine, otherwise it ignores the interrupt. Here is my code.

#include <SPI.h>

const byte interruptPin = 3;
const byte clk = 15, data = 16, latch = 5, ledpin = 17, nr_inputs = 4;
byte z = 0;

void setup() {
 // put your setup code here, to run once:
 pinMode(clk, OUTPUT);
 pinMode(data, OUTPUT);
 pinMode(latch, OUTPUT);
 pinMode(interruptPin, INPUT);
 
 SPI.setBitOrder(MSBFIRST);
 SPI.setDataMode(SPI_MODE0);
 SPI.setClockDivider(SPI_CLOCK_DIV2);
 SPI.begin();
 
 attachInterrupt(0, sh_reg_int, RISING);

 SPI.transfer(3);
 SPI.transfer(255);
 digitalWrite(latch, 1);
 digitalWrite(latch, 0);

}

void loop() {
 // put your main code here, to run repeatedly:
 
 
}

void sh_reg_int(){
  
 for(int i=0; i<3; i++){
   
   bitWrite(z,i,!bitRead(z,i));  
   SPI.transfer(z);
   SPI.transfer(255);
   digitalWrite(latch, 1);
   digitalWrite(latch, 0);
   delay(1000);
 }
 
}