EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

SPI interface -- newbie --plz help

Started by abhay October 4, 2006
hi,
i am trying to use SPI in my application.i want to have communication
between two sdk's
LPC2138 & LPC935. i have configured LPC2138 as master & other as
slave.but i am not getting
output on slave . i am sending a character string from master and want
the slave to display it
through hyperterminal.

one thing i want to verify before others ,is that ,can i experiment
this with simple copper wires
or i would need some other bus because copper wires can add delays &
disturb the clock
synchronization.

what should i do?

abhay wrote:
> hi, > i am trying to use SPI in my application.i want to have communication > between two sdk's > LPC2138 & LPC935. i have configured LPC2138 as master & other as > slave.but i am not getting > output on slave . i am sending a character string from master and want > the slave to display it > through hyperterminal. > > one thing i want to verify before others ,is that ,can i experiment > this with simple copper wires > or i would need some other bus because copper wires can add delays & > disturb the clock > synchronization. > > what should i do?
SPI means the clock (SCK) is sent from the master to the slave. And yes, Copper wire has a delay of 4.5ns per meter, about 50% more than free space. See your physics teacher for less delay. Rene -- Ing.Buero R.Tschaggelar - http://www.ibrtses.com & commercial newsgroups - http://www.talkto.net
"abhay" <abhaym244@gmail.com> wrote in message 
news:1159962573.318524.46150@h48g2000cwc.googlegroups.com...
> hi, > i am trying to use SPI in my application.i want to have communication > between two sdk's > LPC2138 & LPC935. i have configured LPC2138 as master & other as > slave.but i am not getting > output on slave . i am sending a character string from master and want > the slave to display it > through hyperterminal. > > one thing i want to verify before others ,is that ,can i experiment > this with simple copper wires > or i would need some other bus because copper wires can add delays & > disturb the clock > synchronization. > > what should i do? >
Wire length is very important especially at high SPI speeds. I suggest starting with a very low clock speed and fairly short connections (under a foot). Still you may need to use twisted pairs to keep noise and crosstalk down. Extraneous pulses on the clock line are death to data on SPI. At the risk of being too basic, make sure you are connected correctly. The Master Out - Slave In (MOSI) line of the master goes to the same line on the slave. If you want return communication the Master In - Slave Out (MISO) signals need to be connected together. If you need an analyzer I highly recommend the Techtools Digiview. It is a great general purpose USB based logic analyzer, sells for $500 US and has SPI analysis software included. Scott
thanks for your replies,
i am trying my experimentation  with a very small distance in between.
wires with about 20cm length.
will that also pose any problem?does there come any bus specific to spi.

abhay wrote:
> thanks for your replies, > i am trying my experimentation with a very small distance in between. > wires with about 20cm length. > will that also pose any problem?does there come any bus specific to spi. >
No 1 out of 1,000,000 times it may be a wire. The other 999,999 times it _WILL_ be your software. donald
"Donald" <donald@dontdoithere.com> wrote in message 
news:LvydnVcoN7OGxrnYnZ2dnUVZ_u-dnZ2d@forethought.net...
> abhay wrote: >> thanks for your replies, >> i am trying my experimentation with a very small distance in between. >> wires with about 20cm length. >> will that also pose any problem?does there come any bus specific to spi. >> > No > > 1 out of 1,000,000 times it may be a wire. > > The other 999,999 times it _WILL_ be your software. > > donald
Exactly. Scott
hi,
i need to use spi in my application but before that i want to do some
experimentation
on that through my sdk kits ?
now i am doing my spi communication with short leads(nearly 10 cm).
i m sending character string from master and trying to print that on
hyperterminal on slave side.but its not showing me the string on slave
side.
Do i need to configure clk on slave side also ? however i suppose that
it should take
its clock from master itself.

what will clock setting on slave side do?
then what does clock synchronisation mean in spi interface ?
also i have provided  both sdk's with common ground.the interrupt on
slave side is generated when i switch off master (but it happens
sometime only).

please suggest something ?

manoj wrote:
> hi, > i need to use spi in my application but before that i want to do some > experimentation > on that through my sdk kits ? > now i am doing my spi communication with short leads(nearly 10 cm). > i m sending character string from master and trying to print that on > hyperterminal on slave side.but its not showing me the string on slave > side. > Do i need to configure clk on slave side also ? however i suppose that > it should take > its clock from master itself. > > what will clock setting on slave side do? > then what does clock synchronisation mean in spi interface ? > also i have provided both sdk's with common ground.the interrupt on > slave side is generated when i switch off master (but it happens > sometime only). > > please suggest something ?
First thing is to make absolutely sure that you understand how SPI works - get a specification. SPI consits of a master and a slave, where the master is responsible for driving the clock signal on BOTH the transmit AND receive cycles. If a SPI master wants to receive information, it must clock the data back from the slave and in the process it will transmit data. It may be real or dummy data. Data is transfered from MOSI (master out slave in) and SOMI (slave out master in). Sometimes there is also a slave transmit enable, which is often times used as a chip select for when there are multiple slave devices. Depending on your platform it may be possible to adjust the clock phasing which would influence whether data is transmitted or recieved on the rising or falling edges and any delays. Typically data will be transmitted on one edge and received on the subsequent edge of the same clock pulse.
>From the brief description, your electrical connections sound like they
should work, at least for a prototype / debugging application. I wouldn't necessarilly rely on your arrangement for a production environment. You should be able to look at the signals with a scope or a logic analyzer. It will robably be easier to interpet what is happening with a logic analyzer, though a scope may give you a better idea of the signal quality. If you find you hook a scope up to your system and it changes its behavior, it is a pretty good indication that you have an electrical or signalling issue. You will also need to be sure that the signal voltages are compatible with both devices and be carefull wheb connecting the system grounds together.
Noway2 wrote:

> First thing is to make absolutely sure that you understand how SPI > works - get a specification. SPI consits of a master and a slave,
_Is_ there "a" specification for SPI? It seems to be considerably fuzzier than, say, I2C. I could not find "a" SPI spec when I was writing my last book. I could find only general information from Motorola^H^H^H^H^H^H^H^H^HFreescale.
Noway2 wrote:

> First thing is to make absolutely sure that you understand how SPI > works - get a specification. SPI consits of a master and a slave,
_Is_ there "a" specification for SPI? It seems to be considerably fuzzier than, say, I2C. I could not find "a" SPI spec when I was writing my last book. I could find only general information from Motorola^H^H^H^H^H^H^H^H^HFreescale.

The 2024 Embedded Online Conference