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.
With MDK 5 in use ( http://www2.keil.com/mdk5 ):
1. Install the corresponding Arm Legacy Pack:
http://www.keil.com/support/docs/4184.htm
2. Follow the "MCB2130 User's Guide" introducing a Blinky project:
http://www.keil.com/support/man/docs/mcb2130/mcb2130_ex_blinky.htm
Beside:
If you're new to Keil MDK take a look at our:
- "Getting Started Guide":
http://www2.keil.com/docs/default-source/default-document-library/mdk5-getting-started.pdf
- "MDK Video Tutorials":
http://www2.keil.com/video
Thanks a lot for your suggestions. I will look at these. But if you can help with this : when I receive 0xff to S0SPDR register shouldn't have outputs go high?