This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SPI LED blink problem. What am I doing wrong ?

Hi. I am new on programming arm products. I am just trying to blink a led by using SPI protocol with LPC2138. But I didn't understan what i am doing wrong.

here is my master code :

#include <lpc213x.h>




int main(void)
{
PINSEL0 = (1<<8)|(1<<10)|(1<<12);
IOSET0 = 1<<7;
IODIR0 = 1<<7;
S0SPCCR=8;
S0SPCR = 0x38;  //Master Select
IOCLR0=(1<<7);


     S0SPDR=0xff;                 //Data transmission
     while(!(S0SPSR&(1<<7)));   //Status check
     S0SPDR=0xff;


		
	
}

here is my slave code : 

#include<lpc213x.h>


int main(){
	PINSEL0 = (1<<8)|(1<<10)|(1<<12);
	IODIR0 = 0<<7;
	S0SPCR = 0x24;
	IODIR1=0xff;
	
	
	while (1){
	
		 IOSET1=S0SPDR;
		 while(!(S0SPSR&(1<<7)));   //Status check
     
		
		
		 IOSET1=S0SPDR;
	
	}
}

actually I took master code from https://www.gadgetronicx.com/spi-protocol-tutorial-arm/ and I tried to write a simple slave code. Sorry for my English.