LPC2129 SPI sniffer help please

Started by rf_equip April 25, 2009
I am trying to make a SPI sniffer with the two SPI ports on the LPC2129 to capture a SPI bus master and slave transaction. I am not using interrupts yet and just polling. Both SPI ports are set as slaves. I have tied both SSEL pins to ground. I am reading data but I am a couple of bits off from what I see on the O'scope. Do you have any ideas. I have read the errata and it does not apply to my case (i.e. CHPA high). This is how I initialize the ports:

PINSEL0 = 0x00055505; //Enable SPI0 pins
PINSEL1 = 0x000002A8; // Enable SPI1 pins
S0SPCCR = 0x0000003a; //Set bit timing running around 1 MHz
S1SPCCR = 0x0000003a;
S0SPCR = 0x00000018; // CPHA =1 CPOL =1
S1SPCR = 0x00000018;

I am constantly polling the SSPSR register looking for errors. I get no errors. When the SPIF is set on both ports I read the data. I even have a delay before reading the SSPDR.

SPI0_Init();
DEBUGOUT(runing);

stat0 = S0SPSR;
stat1 = S1SPSR;

i=0;
while(i<100)
{

stat0 = S0SPSR;
stat1 = S1SPSR;

if (stat0 & 0x78)
DEBUGOUT(SPI0); // SPI0 error

if (S1SPSR & 0x78)
DEBUGOUT(SPI1); // SPI1 error

if ((stat0 & 0x80) & (stat1 & 0x80))
{
for (j=0;j<2;j++); // a little delay before reading
data0[i] = S0SPDR;
data1[i] = S1SPDR;
i++;
}
}
Thanks for your help in advance,

Sal

An Engineer's Guide to the LPC2100 Series

"Both SPI ports are set as slaves."
Why do you use two slaves ?
2009/4/25 rf_equip

> I am trying to make a SPI sniffer with the two SPI ports on the LPC2129 to
> capture a SPI bus master and slave transaction. I am not using interrupts
> yet and just polling. Both SPI ports are set as slaves. I have tied both
> SSEL pins to ground. I am reading data but I am a couple of bits off from
> what I see on the O'scope. Do you have any ideas. I have read the errata and
> it does not apply to my case (i.e. CHPA high). This is how I initialize the
> ports:
>
> PINSEL0 = 0x00055505; //Enable SPI0 pins
> PINSEL1 = 0x000002A8; // Enable SPI1 pins
>
> S0SPCCR = 0x0000003a; //Set bit timing running around 1 MHz
> S1SPCCR = 0x0000003a;
> S0SPCR = 0x00000018; // CPHA =1 CPOL =1
> S1SPCR = 0x00000018;
>
> I am constantly polling the SSPSR register looking for errors. I get no
> errors. When the SPIF is set on both ports I read the data. I even have a
> delay before reading the SSPDR.
>
> SPI0_Init();
> DEBUGOUT(runing);
>
> stat0 = S0SPSR;
> stat1 = S1SPSR;
>
> i=0;
> while(i<100)
> {
>
> stat0 = S0SPSR;
> stat1 = S1SPSR;
>
> if (stat0 & 0x78)
> DEBUGOUT(SPI0); // SPI0 error
>
> if (S1SPSR & 0x78)
> DEBUGOUT(SPI1); // SPI1 error
> if ((stat0 & 0x80) & (stat1 & 0x80))
> {
> for (j=0;j<2;j++); // a little delay before reading
> data0[i] = S0SPDR;
> data1[i] = S1SPDR;
> i++;
> }
> }
>
> Thanks for your help in advance,
>
> Sal
>
>
>


Because there are two lines to listen to, I imagine. MISO and MOSI. A
slave is only going to listen to MOSI, a master MISO. Thus, to monitor both
sides of the transaction, he'd need two receivers.
--jc

On Mon, May 4, 2009 at 4:27 AM, tomi wrote:

> "Both SPI ports are set as slaves."
> Why do you use two slaves ?
>
> 2009/4/25 rf_equip >
> >
> >
> > I am trying to make a SPI sniffer with the two SPI ports on the LPC2129
> to
> > capture a SPI bus master and slave transaction. I am not using interrupts
> > yet and just polling. Both SPI ports are set as slaves. I have tied both
> > SSEL pins to ground. I am reading data but I am a couple of bits off from
> > what I see on the O'scope. Do you have any ideas. I have read the errata
> and
> > it does not apply to my case (i.e. CHPA high). This is how I initialize
> the
> > ports:
> >
> > PINSEL0 = 0x00055505; //Enable SPI0 pins
> > PINSEL1 = 0x000002A8; // Enable SPI1 pins
> >
> > S0SPCCR = 0x0000003a; //Set bit timing running around 1 MHz
> > S1SPCCR = 0x0000003a;
> > S0SPCR = 0x00000018; // CPHA =1 CPOL =1
> > S1SPCR = 0x00000018;
> >
> > I am constantly polling the SSPSR register looking for errors. I get no
> > errors. When the SPIF is set on both ports I read the data. I even have a
> > delay before reading the SSPDR.
> >
> > SPI0_Init();
> > DEBUGOUT(runing);
> >
> > stat0 = S0SPSR;
> > stat1 = S1SPSR;
> >
> > i=0;
> > while(i<100)
> > {
> >
> > stat0 = S0SPSR;
> > stat1 = S1SPSR;
> >
> > if (stat0 & 0x78)
> > DEBUGOUT(SPI0); // SPI0 error
> >
> > if (S1SPSR & 0x78)
> > DEBUGOUT(SPI1); // SPI1 error
> >
> >
> > if ((stat0 & 0x80) & (stat1 & 0x80))
> > {
> > for (j=0;j<2;j++); // a little delay before reading
> > data0[i] = S0SPDR;
> > data1[i] = S1SPDR;
> > i++;
> > }
> > }
> >
> > Thanks for your help in advance,
> >
> > Sal
> >
> >
> >
>
>
>