Thanks for the reply.
I just want to confirm that my code for the master to receive is valid, also is shown my modified code for the slave.
// Master
byte SPItransfer (byte val)
{
// First send, then receive
while(!SPIS_SPTEF);
SPID = val;
while(!SPIS_SPRF);
return SPID;
}
/////////////////////////////////////////////////////////////////////////////////////
//Master
void laserComm(char Data[])
{
if (Data[0] == 'X')PTCD_PTCD6 = 0; //Pull low to select correct slave
if (Data[0] == 'Y')PTCD_PTCD5 = 0; //Pull low to select correct slave
if (Data[0] == 'Z')PTCD_PTCD4 = 0; //Pull low to select correct slave
for(laserCommCount=0; laserCommCount <= dataSize ; laserCommCount++)
SPIdataIn[laserCommCount] = SPItransfer(Data[laserCommCount]);
PTCD_PTCD6 = 1; // Pull high after data transfer
PTCD_PTCD5 = 1;
PTCD_PTCD4 = 1;
}
/////////////////////////////////////////////////////////////////////////////////////
//Slave receive function
interrupt 15 // SPI receive interrupt
void receiveSPI (void)
{
(void)SPIS; // Clear flags
SPIdataIn[SPIReceiveIndex] = SPID; // Receive byte
SPID = Packet1[SPIReceiveIndex]; // Load byte to send
if (SPIReceiveIndex == dataSize)
{
SPIdataReceived = 1; // Indicate the data has been received
SPIReceiveIndex = 0; // Reset receive index
}
else SPIReceiveIndex++;
}
Also I still don't seem to be receiving the data I expect. Are there any timing considerations?