Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI problem- communication successful only with 1-byte data

Status
Not open for further replies.

grindylow

Newbie level 6
Joined
Sep 4, 2009
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,367
SPI String

I have successfully used SPI communications between two microcontrollers. That was when I am sending 1-byte data, but when I used to transfer a string the slave seems to be getting only the first byte, can you tell why is this happening?
here is the master code:
Code:
if(slave == TRUE)
{
	 CSpin=0;
	 Delay10TCYx(50);
	 putsSPI(slave_stream);
	 CSpin=1;
	 count++;
	 if(count==10) {
	  slave = FALSE;
	  count=0;
	 }
}
here is the slave code:
Code:
if(DataRdySPI()) {
  getsSPI(master_stream, 5);
 
  received_data0 = master_stream[0];
  received_data1 = master_stream[1];
  received_data2 = master_stream[2];
  received_data3 = master_stream[3];

  switch(received_data0)
  {
	case 'A':
	 LED=0;
	 for(i=0;i<8;i++)
  	  Delay10KTCYx(0);
 	 Delay10KTCYx(176);
	 Delay10KTCYx(176);
	break;
	case 'B':
	 servo0=0xFBC6;
	break;
	case 'N':
	 servo0=0xF1FD;
	break;
	default: break;
  }

 if(received_data1 == 'N') {       //<-------------this part doesn't get executed
	for(i=0;i<8;i++)
  	  Delay10KTCYx(0);
 	 Delay10KTCYx(176);
	 Delay10KTCYx(176);
	 servo0=0xF883;
 }

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top