AWOL:
I've worn a groove in my tablet's screen scrolling through this thread.
Nick, you deserve a medal.
Hi...!!!
I have tried all the possible combinations , Slave is not able to send back data to master for each if conditions.
#include "pins_arduino.h"
#include <SPI.h>
#define SS 10
int dat[24] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14};
byte c;
int m, n ;
void setup (void)
{
// have to send on master in, *slave out*
pinMode(MISO, OUTPUT);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode (SPI_MODE2);
SPI.setClockDivider(SPI_CLOCK_DIV64) ;
// turn on SPI in slave mode
SPCR |= _BV(SPE);
// turn on interrupts
SPCR |= _BV(SPIE);
// disable timer interrupts
TIMSK0 = 0;
} // end of setup
// SPI interrupt routine
ISR (SPI_STC_vect)
{
c = SPDR;
if(c == 0x00)
{
SPDR = 0x01;
}
else if(c == 0x06)
{
SPDR = 0x02;
}
else if(c == 0x08)
{
SPDR = 0x03;
}
else if(c == 0x0A)
{
SPDR = 0x07;
}
else
SPDR = 0; // what to return to the master
} // end of interrupt service routine (ISR) SPI_STC_vect
void loop (void)
{
} // end of loop