Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: SPI MOSI NOT RESPONDING

2005-04-05 by Mark Butcher

Hallo Rajendra

I think you have the following problems

while (Length--)
{
IOSET = 0x80; // remove SSEL      ------------------ 1/2
SPI_SPDR = *ptrData++; // Set data Byte
while((SPI_SPSR & 0x80)==0);
IOCLR = 0x80; // activate SSEL    ------------------ 3
*Rx++ = (unsigned char)SPI_SPDR;
}
for(short i=0;i<=7;i++)
{
while(U0LSR==0x00){;}
U0THR = Tx1[i] ;
}
}

1. The SPI has a problem with the SSEL line. You are using it as a 
general purpose port which doesn't work. You have to leave the SSEL 
line programmed as SSEL and use another general purpose I/O as SSEL 
output. [if the SSEL line is not programmed as SSEL and is not 
pulled high the SPI doesn't work in master mode.]

2/3. You are controlling the polarity inversely to the code which I 
suggested. SSEL must be set low at 1/2 and removed (high) at 3.

Summary:
#define MY_SSEL 0x40   // use P0.6 as SSEL output
PINSEL0 &= ~0x0000ff00;
PINSEL0 |= 0x00005500; // use all SPi lines as special purpose
IOSET = MY_SSEL;       // 
IODIR |= MY_SSEL ;     // drive my SSEL output high

...
...


while (Length--)
{
IOCLR = MY_SSEL;       // activate SSEL ('0')
SPI_SPDR = *ptrData++; // Set data Byte
while((SPI_SPSR & 0x80)==0);   // wait for Tx and Rx to complete
IOCLR = 0x80;         // remove SSEL ('1')
*Rx++ = (unsigned char)SPI_SPDR; // store received byte for later
}

This should work then (don't forget to pull up the real SSEl line 
to '1').

Regards

Mark

www.mjbc.ch





--- In lpc2000@yahoogroups.com, "rockraj_2003" <rockraj_2003@y...> 
wrote:
> 
> Hello Mark,
> 
> I am using SPI to configure the DP1203.
> 
> LPC2106 - FULL DUPLEX.
> DP1203 - HALF DUPLEX.
> 
> I just wrote ur program in IAR but when the SSEL is low it's not 
> responding.
> There is no SCK.
> 
> When SSEL pin is high it's responding correctly.
> I can able to see the Serial Clock and the Data Transmission in 
the 
> MOSI line as well.
> But I can't able to receive any data in the MISO line.
> It's in low state. There is no response.
> 
> When i transmit the Tx1 it's giving only "00" for 8 times.
> Here is the simple code. 
> 
> #include "LPC210x.H"
> #include "ma_uart0.h"
> 
> void main (void)
> {
>  unsigned char Tx[] = {1,2,3,4,5,6,7,8}; 
>  unsigned char Tx1[8];
> 
>  unsigned short Length;
> 
>  unsigned char *ptrData,*Rx;
> 
>  MA_Init_UART0();
>  MA_Reset_UART0();
>  Length = sizeof(Tx);
> 
>  ptrData = Tx;
>  VPBDIV = 0;
>  Rx = Tx1;
>  
>  IODIR = 0x80;
>  IOSET = 0x80;
>  PINSEL0 = 0x5505;
>  SPI_SPCCR = 0xFF;
>  SPI_SPCR = 0x20;
> 
> while (Length--) 
> {
>   IOSET = 0x80; // remove SSEL
>   SPI_SPDR = *ptrData++; // Set data Byte
>   while((SPI_SPSR & 0x80)==0);
>   IOCLR = 0x80; // activate SSEL
>   *Rx++ = (unsigned char)SPI_SPDR;
> }  
> for(short i=0;i<=7;i++)
>   {
>     while(U0LSR==0x00){;}
>     U0THR = Tx1[i] ;  
>     }
> }
> 
> Kindly Help me to solve the probl.
> 
> Is there any other example code that send as well as receive data 
in 
> MOSI & MISO line throu SCK.
> 
> with regards,
> Rajendra R
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.