SPI communication between Nano and ATTiny24

Hello, I'm trying to make a communication between Arduino Nano and ATTiny24 using SPI. I've written code for master(Nano) and slave(ATTiny24)(with great difficulty) but no luck getting proper output. I'm transmitting '1' on both sides for simplicity. Heres the code:
Master code (nano):

#include<SPI.h> 
#define SSpin 10
void setup (void)

{
  Serial.begin(9600);                                 
  
  SPI.begin();                            
  SPI.setClockDivider(SPI_CLOCK_DIV16); 
  digitalWrite(SSpin,HIGH);                  
}

void loop(void)
{
  byte m_send,m_receive;          
  digitalWrite(SSpin, LOW);
  m_send=1;                                       
  m_receive=SPI.transfer(m_send);
  Serial.println(m_receive);     //should print 1 here but it prints 255 always
  delay(1000);
}

Slave(ATTiny24):

int data;
void setup()
{
  DDRB=(1<<PA5)|(0<<PA6)|(0<<PA4); 
  USICR = (1<<USIWM0)|(1<<USICS1);
}

void loop()
{
  data=slaveSPITransfer(1);
  if(data==1)
  {
    digitalWrite(PA1,HIGH);
  }
  else
  {
    digitalWrite(PA1,LOW);
  }
}

uint8_t slaveSPITransfer(uint8_t val) 
{
  USIDR = val;
  USISR = (1<<USIOIF);
  while (! (USISR & (1<<USIOIF)));
  return USIDR;
}

Any help will be appreciated.

Schematics?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.