Hello Mark,
Thanks for Ur Response.I tried Ur Code its working fine.
I aslo changed my prog.This Code is also giving the Same response.
I didn't CLR the SSEL pin at all.But I regularly changed SPIF to 0x00.
Now, my doubt is if i want to use MISO as well what should i do.
Since in the Data Sheet THE mentioned SPI as duplex.
How I can use MISO.
Silly Question, but I don't know about this.
If the SPI is in MOSI, it can send DATA (MASTER OUTPUT) at the Same
time it receive data in SLAVE.(SLAVE INPUT).How much time it will
wait to receive DATA. If again I put some Data to the SPI_SPDR it
will transmit or it will wait to receive.
> > #define SPI_SPCR (*((volatile unsigned char *) 0xE0020000))
> > #define SPI_SPSR (*((volatile unsigned char *) 0xE0020004))
> > #define SPI_SPDR (*((volatile unsigned char *) 0xE0020008))
> > #define SPI_SPCCR (*((volatile unsigned char *) 0xE002000C))
> > #define SPI_SPTCR (*((volatile unsigned char *) 0xE0020010))
> > #define SPI_SPTSR (*((volatile unsigned char *) 0xE0020014))
> > #define SPI_SPTOR (*((volatile unsigned char *) 0xE0020018))
> > #define SPI_SPINT (*((volatile unsigned char *) 0xE002001C))
> >
> > int main (void)
> > {
> > int i;
> > VPBDIV = 1;
> > IODIR = 0x80;
> > IOSET = 0x80;
> > PINSEL0 = 0x5500;
> > SPI_SPCCR = 0x93;
> > SPI_SPCR = 0x20;
> > while (1) {
> > do SPI_SPDR = 0x55;
> > while((SPI_SPSR & 0x80)==0);
> > SPI_SPSR = 0x00;
> > do SPI_SPDR = 0x0F;
> > while((SPI_SPSR & 0x80)==0);
> > SPI_SPSR = 0x00;
> > do SPI_SPDR = 0xF0;
> > while((SPI_SPSR & 0x80)==0);
> > SPI_SPSR = 0x00;
> > }
> > }
with Regards
Rajendra R
--- In lpc2000@yahoogroups.com, "Mark Butcher" <M_J_Butcher@I...>
wrote:
>
> Hallo Rajendra
>
> The initialisation seems OK - 100k in master mode.
>
> Make sure the SSEL pin is pulled up to '1' - there is an error in
> the device which doesn't allow sending if this is not the case.
>
> Try the following transmission code - eg
>
> unsigned char ucTest[] = {1,2,3,4,5};
>
> fnSendSPIMessage(ucTest, sizeof(ucTest));
>
> void fnSendSPIMessage(unsigned char *ptrData, unsigned short
> usLength)
> {
> while (!(SPI_SPSR & SPIF)) {}; // wait for transmitter free
> // ensures that write works
> while (usLength--) {
> IOCLR = SPI_SSEL_OUT; // activate SSEL
> SPI_SPDR = *ptrData++; // Set data Byte
> while (!(SPI_SPSR & SPIF)) {}; // wait for transmission to
> complete
> IOSET = SPI_SSEL_OUT; // remove SSEL
> }
> }
>
> Note: SPI_SSEL_OUT is an output port to contol the SSEL line to the
> slave - the LPC2104 doesn't do this itself and SSEL can not be used
> for this purpose (needs the pullup and can not be programmed as
> output).
> SPIF is 0x80.
>
> This may help. The LPC2104 works OK as master but the SSEL line has
> to be wasted. As slave I gave up because it just didn't send
> sensible data back...
>
> Regards
>
> Mark Butcher
>
> www.mjbc.ch
>
> --- In lpc2000@yahoogroups.com, "rockraj_2003" <rockraj_2003@y...>
> wrote:
> >
> > HELLO FRIENDS,
> >
> > No body giving me suggestion on how to program SPI.
> > My real task is to configure "DP1203" by using LPC2104.
> > The only way to configure DP1203 is throu "SPI".
> > I got an example file from Keil.
> > Its working and producing SCK(Serial Clock).
> > I fixed the Clk Frequency at 100Khz. But I am getting only 40 Mhz.
> > I just Send an 8 bit Data After if i send other Data its not
> > reponding.
> > The SCK pin is in low State.
> > The "DP1203" has got 8 address bit and 8 data bit.
> > So totally 16 bit for One Configuration of Registers.
> > But I want to Configure more than 20 Registers.
> > Can any one Suggest me where i am doing the mistake.
> >
> > Here is the Code
> > #include <LPC210x.H>
> >
> > #define SPI_SPCR (*((volatile unsigned char *) 0xE0020000))
> > #define SPI_SPSR (*((volatile unsigned char *) 0xE0020004))
> > #define SPI_SPDR (*((volatile unsigned char *) 0xE0020008))
> > #define SPI_SPCCR (*((volatile unsigned char *) 0xE002000C))
> > #define SPI_SPTCR (*((volatile unsigned char *) 0xE0020010))
> > #define SPI_SPTSR (*((volatile unsigned char *) 0xE0020014))
> > #define SPI_SPTOR (*((volatile unsigned char *) 0xE0020018))
> > #define SPI_SPINT (*((volatile unsigned char *) 0xE002001C))
> >
> > int main (void)
> > {
> > int i;
> > VPBDIV = 1;
> > IODIR = 0x80;
> > IOSET = 0x80;
> > PINSEL0 = 0x5500;
> > SPI_SPCCR = 0x93;
> > SPI_SPCR = 0x20;
> > while (1) {
> > do SPI_SPDR = 0x55;
> > while((SPI_SPSR & 0x80)==0);
> > for(i=0;i<10000;i++);
> > SPI_SPSR = 0x00;
> > do SPI_SPDR = 0x0F;
> > while((SPI_SPSR & 0x80)==0);
> > goto OUT;
> > }
> >
> > OUT: for(i=0;i<1000;i++);
> >
> > while (1) {
> > do SPI_SPDR = 0xF0;
> > while((SPI_SPSR & 0x80)==0);
> > for(i=0;i<100000;i++);
> > goto OUT;
> > }
> > }
> >
> >
> >
> >
> >
> >
> > Thank U,
> >
> > with Regards,
> > Rajendra RMessage
Re: SPI RESPONDING
2005-03-15 by rockraj_2003
Attachments
- No local attachments were found for this message.