EmbeddedRelated.com
Forums

questions about LPC2106 SPI

Started by hemanandharamesh July 13, 2009
Hai dudes,
I'm interfacing Ethernet chip W5100 with the lpc2106 by SPI.., can anybody tell me what should be done for interfacing the chip with lpc2106., im using the GPIO pins P0.4,0.5,0.6,0.7 for SPI.Is below code enough for initialization?

/* Include header file depending upon part used */

#include"LPC2.h"
void Initialize(void);
#define SPIF (1<<7) /* Macro Definitions */
#define DATA 0xC1
************************* MAIN *************************/
int main()
{
Initialize();
while(1) /* Do forever */
{
SPDR=DATA; /* Write data out */
while(!(SPSR & SPIF)){} /* Wait for transfer to be completed */
}
}
/*************** System Initialization ***************/
void Initialize()
{
PINSEL0=0x5500; /* Configure Pin Connect Block */
VPBDIV=0x1; /* Set pclk to same as cclk */
SPCCR=0x8; /* Set to highest speed for SPI at 10 MHz- > 1.25 MHz */
SPCR=0x20; /* Device selected as master */
}

/*********************************************************/

An Engineer's Guide to the LPC2100 Series

Donot select the SSEL.select it as p0.7 general purpose.

R u getting the SCK0 clock on oscilloscope? check this.

--- In l..., "hemanandharamesh" wrote:
>
> Hai dudes,
> I'm interfacing Ethernet chip W5100 with the lpc2106 by SPI.., can anybody tell me what should be done for interfacing the chip with lpc2106., im using the GPIO pins P0.4,0.5,0.6,0.7 for SPI.Is below code enough for initialization?
>
> /* Include header file depending upon part used */
>
> #include"LPC2�.h"
> void Initialize(void);
> #define SPIF (1<<7) /* Macro Definitions */
> #define DATA 0xC1
> ************************* MAIN *************************/
> int main()
> {
> Initialize();
> while(1) /* Do forever */
> {
> SPDR=DATA; /* Write data out */
> while(!(SPSR & SPIF)){} /* Wait for transfer to be completed */
> }
> }
> /*************** System Initialization ***************/
> void Initialize()
> {
> PINSEL0=0x5500; /* Configure Pin Connect Block */
> VPBDIV=0x1; /* Set pclk to same as cclk */
> SPCCR=0x8; /* Set to highest speed for SPI at 10 MHz- > 1.25 MHz */
> SPCR=0x20; /* Device selected as master */
> }
>
> /*********************************************************/
>

As I read the data sheets, SSEL must be 1 for SPI to work in the /00 chips, and perhaps in the rev /01 chips too. So chip select has to be implemented with a separate GPIO bit or not sourced by the ARM.

I have a huge collection of applications/protocols in C for an AVR that works with a WizNet5100 chip under an RTOS called AVRx. I'm porting that to an ARM2106/2129 and a different OS.

SPI works for me on the '2106 with the code you've shown.
Checked with 'scope.
--- In l..., "raju_nem" wrote:
>
>
> Donot select the SSEL.select it as p0.7 general purpose.
>
> R u getting the SCK0 clock on oscilloscope? check this.
>
>
>
>
>
>
>
>
> --- In l..., "hemanandharamesh" wrote:
> >
> > Hai dudes,
> > I'm interfacing Ethernet chip W5100 with the lpc2106 by SPI.., can anybody tell me what should be done for interfacing the chip with lpc2106., im using the GPIO pins P0.4,0.5,0.6,0.7 for SPI.Is below code enough for initialization?
> >
> > /* Include header file depending upon part used */
> >
> > #include"LPC2�.h"
> > void Initialize(void);
> > #define SPIF (1<<7) /* Macro Definitions */
> > #define DATA 0xC1
> > ************************* MAIN *************************/
> > int main()
> > {
> > Initialize();
> > while(1) /* Do forever */
> > {
> > SPDR=DATA; /* Write data out */
> > while(!(SPSR & SPIF)){} /* Wait for transfer to be completed */
> > }
> > }
> > /*************** System Initialization ***************/
> > void Initialize()
> > {
> > PINSEL0=0x5500; /* Configure Pin Connect Block */
> > VPBDIV=0x1; /* Set pclk to same as cclk */
> > SPCCR=0x8; /* Set to highest speed for SPI at 10 MHz- > 1.25 MHz */
> > SPCR=0x20; /* Device selected as master */
> > }
> >
> > /*********************************************************/
>