Forums

spi in lpc2106

Started by Jeetendra Singh April 8, 2005

Hi friends

i am working in Lpc2106 and facing problem in spi mdule.
Actualy i am using spi module in master mode. i checked my code in
jtag debugger(wiggler in CrossStudio)and found that when writing data
to the SPDR register then SPif bit in SPSR also sets showing that
data is transmitted.

But the problem is that nither data nor clocks in the MOSI & SCK pins. If some body can help me i will be very thank ful to him.

jeetendra

My source code attached
int main (void){ IOSET=0x80;
IODIR=0x00;

PINSEL0 = 0x00005500;

//Config over
init_spi();

IOSET = MMC_CS; // Chip select High
MmCardSendByte(0xAA);
IOCLR = MMC_CS; // Chip select Low

while (1);
}

void init_spi(){
unsigned char ch; IODIR |= MMC_CS; // io direction of mc chip select
IOSET = MMC_CS; // Chip select High

SPCCR = 0xfe; // clock counter
SPCR = 0x20; // spi master mode,

// ch = SPDR;// data read

}

BYTE MmCardSendByte(BYTE bt)
{
BYTE input;
SPDR = bt;
while (!(SPSR & 0x80));
input = SPDR;

return input;
}


An Engineer's Guide to the LPC2100 Series


Hello
I have the same problem a days ago.
You need:
-Apply 3v3 to pin SSEL0 (SSEL1)
- In the pin Connect block put this pin as connected to SPI
- Use another pin as CS

Regards

--- In lpc2000@lpc2..., "Jeetendra Singh" <jeet77_7@y...>
wrote:
>
> Hi friends
>
> i am working in Lpc2106 and facing problem in spi mdule.
> Actualy i am using spi module in master mode. i checked my code in
> jtag debugger(wiggler in CrossStudio)and found that when writing
data
> to the SPDR register then SPif bit in SPSR also sets showing that
> data is transmitted.
>
> But the problem is that nither data nor clocks in the MOSI & SCK
pins.
>
>
> If some body can help me i will be very thank ful to him.
>
> jeetendra
>
> My source code attached
> int main (void){ > IOSET=0x80;
> IODIR=0x00;
>
> PINSEL0 = 0x00005500;
>
> //Config over
> init_spi();
>
> IOSET = MMC_CS; // Chip select High
> MmCardSendByte(0xAA);
> IOCLR = MMC_CS; // Chip select Low
>
> while (1);
> }
>
> void init_spi(){
> unsigned char ch; > IODIR |= MMC_CS; // io direction of mc chip select
> IOSET = MMC_CS; // Chip select High
>
> SPCCR = 0xfe; // clock counter
> SPCR = 0x20; // spi master mode,
>
> // ch = SPDR;// data read
>
> }
>
> BYTE MmCardSendByte(BYTE bt)
> {
> BYTE input;
> SPDR = bt;
> while (!(SPSR & 0x80));
> input = SPDR;
>
> return input;
> }



Is SSEL1 pulled up?
-----Original Message-----
From: Jeetendra Singh [mailto:jeet77_7@jeet...]
Sent: Friday, April 08, 2005 9:44 AM
To: lpc2000@lpc2...
Subject: [lpc2000] spi in lpc2106
Hi friends

i am working in Lpc2106 and facing problem in spi mdule.
Actualy i am using spi module in master mode. i checked my code in
jtag debugger(wiggler in CrossStudio)and found that when writing data
to the SPDR register then SPif bit in SPSR also sets showing that
data is transmitted.

But the problem is that nither data nor clocks in the MOSI & SCK pins. If some body can help me i will be very thank ful to him.

jeetendra

My source code attached
int main (void){ IOSET=0x80;
IODIR=0x00;

PINSEL0 = 0x00005500;

//Config over
init_spi();

IOSET = MMC_CS; // Chip select High
MmCardSendByte(0xAA);
IOCLR = MMC_CS; // Chip select Low

while (1);
}

void init_spi(){
unsigned char ch; IODIR |= MMC_CS; // io direction of mc chip select
IOSET = MMC_CS; // Chip select High

SPCCR = 0xfe; // clock counter
SPCR = 0x20; // spi master mode,

// ch = SPDR;// data read

}

BYTE MmCardSendByte(BYTE bt)
{
BYTE input;
SPDR = bt;
while (!(SPSR & 0x80));
input = SPDR;

return input;
}
----
--
Yahoo! Groups Links

a.. To



You must pull up the SSEL of the SCI that you are using. Seem be that
the SCI in master mode need that the SSELx must be connected and
pulled up externally for correct work. --- In lpc2000@lpc2..., "Mark Crow" <mcrow@p...> wrote:
> Is SSEL1 pulled up?
> -----Original Message-----
> From: Jeetendra Singh [mailto:jeet77_7@y...]
> Sent: Friday, April 08, 2005 9:44 AM
> To: lpc2000@lpc2...
> Subject: [lpc2000] spi in lpc2106 >
> Hi friends
>
> i am working in Lpc2106 and facing problem in spi mdule.
> Actualy i am using spi module in master mode. i checked my code
in
> jtag debugger(wiggler in CrossStudio)and found that when writing
data
> to the SPDR register then SPif bit in SPSR also sets showing that
> data is transmitted.
>
> But the problem is that nither data nor clocks in the MOSI & SCK
pins.
>
>
> If some body can help me i will be very thank ful to him.
>
> jeetendra
>
> My source code attached
> int main (void){ > IOSET=0x80;
> IODIR=0x00;
>
> PINSEL0 = 0x00005500;
>
> //Config over
> init_spi();
>
> IOSET = MMC_CS; // Chip select High
> MmCardSendByte(0xAA);
> IOCLR = MMC_CS; // Chip select Low
>
> while (1);
> }
>
> void init_spi(){
> unsigned char ch; > IODIR |= MMC_CS; // io direction of mc chip select
> IOSET = MMC_CS; // Chip select High
>
> SPCCR = 0xfe; // clock counter
> SPCR = 0x20; // spi master mode,
>
> // ch = SPDR;// data read
>
> }
>
> BYTE MmCardSendByte(BYTE bt)
> {
> BYTE input;
> SPDR = bt;
> while (!(SPSR & 0x80));
> input = SPDR;
>
> return input;
> } >
> --------------------------------
--------
> --
> Yahoo! Groups Links
>
> a.. To >
>




Yes i already Pulled up SSEL to 3v3 by a 47K Resister and not used
for CS(MMC_CS). I am using another GPIO for the purpose of CS
MMC_CS).

Notice that In debugger i seen that after loading data in SPDR , SPIF
sets showing data transmited. --- In lpc2000@lpc2..., "aumat123" <angelsp@a...> wrote:
>
> You must pull up the SSEL of the SCI that you are using. Seem be
that
> the SCI in master mode need that the SSELx must be connected and
> pulled up externally for correct work. > --- In lpc2000@lpc2..., "Mark Crow" <mcrow@p...> wrote:
> > Is SSEL1 pulled up?
> > -----Original Message-----
> > From: Jeetendra Singh [mailto:jeet77_7@y...]
> > Sent: Friday, April 08, 2005 9:44 AM
> > To: lpc2000@lpc2...
> > Subject: [lpc2000] spi in lpc2106
> >
> >
> >
> > Hi friends
> >
> > i am working in Lpc2106 and facing problem in spi mdule.
> > Actualy i am using spi module in master mode. i checked my
code
> in
> > jtag debugger(wiggler in CrossStudio)and found that when
writing
> data
> > to the SPDR register then SPif bit in SPSR also sets showing
that
> > data is transmitted.
> >
> > But the problem is that nither data nor clocks in the MOSI &
SCK
> pins.
> >
> >
> > If some body can help me i will be very thank ful to him.
> >
> > jeetendra
> >
> > My source code attached
> > int main (void){
> >
> >
> > IOSET=0x80;
> > IODIR=0x00;
> >
> > PINSEL0 = 0x00005500;
> >
> > //Config over
> > init_spi();
> >
> > IOSET = MMC_CS; // Chip select High
> > MmCardSendByte(0xAA);
> > IOCLR = MMC_CS; // Chip select Low
> >
> > while (1);
> > }
> >
> > void init_spi(){
> > unsigned char ch;
> >
> >
> > IODIR |= MMC_CS; // io direction of mc chip select
> > IOSET = MMC_CS; // Chip select High
> >
> > SPCCR = 0xfe; // clock counter
> > SPCR = 0x20; // spi master mode,
> >
> > // ch = SPDR;// data read
> >
> > }
> >
> > BYTE MmCardSendByte(BYTE bt)
> > {
> > BYTE input;
> > SPDR = bt;
> > while (!(SPSR & 0x80));
> > input = SPDR;
> >
> > return input;
> > }
> >
> >
> >
> >
> >
> >
> > ------------------------------
--
> --------
> > --
> > Yahoo! Groups Links
> >
> > a.. To
> >
> >
> >
> >




Thanks aumat123

i followed your advice and got the fault actualy SSEL pin was dry
soldered.

Now i am trying to interface MMC card through SPI.

Jeetendra --- In lpc2000@lpc2..., "Jeetendra Singh" <jeet77_7@y...>
wrote:
>
> Yes i already Pulled up SSEL to 3v3 by a 47K Resister and not used
> for CS(MMC_CS). I am using another GPIO for the purpose of CS
> MMC_CS).
>
> Notice that In debugger i seen that after loading data in SPDR ,
SPIF
> sets showing data transmited. > --- In lpc2000@lpc2..., "aumat123" <angelsp@a...> wrote:
> >
> > You must pull up the SSEL of the SCI that you are using. Seem be
> that
> > the SCI in master mode need that the SSELx must be connected and
> > pulled up externally for correct work.
> >
> >
> > --- In lpc2000@lpc2..., "Mark Crow" <mcrow@p...> wrote:
> > > Is SSEL1 pulled up?
> > > -----Original Message-----
> > > From: Jeetendra Singh [mailto:jeet77_7@y...]
> > > Sent: Friday, April 08, 2005 9:44 AM
> > > To: lpc2000@lpc2...
> > > Subject: [lpc2000] spi in lpc2106
> > >
> > >
> > >
> > > Hi friends
> > >
> > > i am working in Lpc2106 and facing problem in spi mdule.
> > > Actualy i am using spi module in master mode. i checked my
> code
> > in
> > > jtag debugger(wiggler in CrossStudio)and found that when
> writing
> > data
> > > to the SPDR register then SPif bit in SPSR also sets showing
> that
> > > data is transmitted.
> > >
> > > But the problem is that nither data nor clocks in the MOSI &
> SCK
> > pins.
> > >
> > >
> > > If some body can help me i will be very thank ful to him.
> > >
> > > jeetendra
> > >
> > > My source code attached
> > > int main (void){
> > >
> > >
> > > IOSET=0x80;
> > > IODIR=0x00;
> > >
> > > PINSEL0 = 0x00005500;
> > >
> > > //Config over
> > > init_spi();
> > >
> > > IOSET = MMC_CS; // Chip select High
> > > MmCardSendByte(0xAA);
> > > IOCLR = MMC_CS; // Chip select Low
> > >
> > > while (1);
> > > }
> > >
> > > void init_spi(){
> > > unsigned char ch;
> > >
> > >
> > > IODIR |= MMC_CS; // io direction of mc chip select
> > > IOSET = MMC_CS; // Chip select High
> > >
> > > SPCCR = 0xfe; // clock counter
> > > SPCR = 0x20; // spi master mode,
> > >
> > > // ch = SPDR;// data read
> > >
> > > }
> > >
> > > BYTE MmCardSendByte(BYTE bt)
> > > {
> > > BYTE input;
> > > SPDR = bt;
> > > while (!(SPSR & 0x80));
> > > input = SPDR;
> > >
> > > return input;
> > > }
> > >
> > >
> > >
> > >
> > >
> > >
> > > ----------------------------
--
> --
> > --------
> > > --
> > > Yahoo! Groups Links
> > >
> > > a.. To
> > >
> > >
> > >
> > >