Shop OBEX P1 Docs P2 Docs Learn Events
SPI vs. TTL serial: Could they be compatible? — Parallax Forums

SPI vs. TTL serial: Could they be compatible?

WhelzornWhelzorn Posts: 256
edited 2007-10-27 06:03 in General Discussion
Ok, so I think I understand how SPI works, and think I understand how serial works. Now for something that should seem to have an obvious answer: could they be compatible?
I don't mean full duplex, but at least in one direction. Heres my idea:

-Serial sends data in one direction per line. It can send one bit at a time, but the rate at which it does so must be known by both the host and the client.
-SPI also sends data in one direction per line. it also sends one bit at a time, but in order for a bit to be sent, it needs to be clocked. So each time the clock line is brought from high to low, it sends a byte.

So theoretically, could the TX line of the serial interface clock the SPI interface? this way, the SPI device will shift bits out of the MOSI line right into the RX line of the serial device. Also, since the TX line is clocking the SPI interface, the baud rate could be set on the SPI line by the speed at which the serial's TX line is clocking it.

There's gotta be something very wrong with this method, because I've seen SPI<--->serial converters, and they seem more complicated than this.

Let me know what you guys think anyway

Thanks, Justin

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-27 02:01
    They are not compatible. A serial interface requires one signal ... the transmit data line. Both the receiver and the transmitter have an internal clock for timing and they synchronize this clock using the start bit of each character cell (the transition from the idle state to the start bit).

    SPI requires a clock transmitted on a 2nd signal line from the data. It is possible to encode the data stream to include the clock information and the data on a single line or single signal. One form of this is called Manchester Encoding ... look it up in the Wikipedia (search the web for "Wiki Manchester Code"), but this is very different from standard asynchronous serial data.
  • WhelzornWhelzorn Posts: 256
    edited 2007-10-27 03:24
    hmmm... alright then. Would you happen know the fastest way to interface a SPI device directly to my PC then? I figured that converting it to serial would be the simplest option, but I'm going to either need a super fast MCU, or some chip designed for the purpose (I don't know of any though).
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-27 03:45
    SPI is an interface "style" if you will. The details vary widely from device to device. If you don't need blinding speed, a Stamp can do the conversion for you ... like maybe 1000 bytes per second tops. If you need something fast, then you'd need an SX or Propeller. Don't forget that the connection to the PC partially limits the overall data rate. Most serial ports on a PC don't work well over 230Kbps for example. That's about 23 thousand bytes per second. Many SPI devices can handle higher clock rates. What kind of device are you thinking about?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-10-27 04:04
    Gents -

    Not to toss any water on this, or create any confusion, but stepping back from this for a moment may be a worthwhile effort. Serial data communication is nothing more or less than bit or byte-wise linear transmission of data through a single conductor. Therefore, a serial data interface CAN have as FEW as one conductior (plus ground), but it may have more as well.

    Within the general serial data transmission scheme, there are two basic methods. Self-timed and externally timed, or asynchronous serial and synchronous serial data transmission as they are more often called. This timing is relative to the pacing of the data travelling across the transmission line.

    A typical asynchronous serial data transmission facility is the (so called) RS-232 method, and a typical synchronous serial method is SPI (serial peripheral interface). There are other methods of both categories as well. From here on in, ground, as a conductor, is no longer mentioned, but presumed to exist in all interface and transmission methods.

    Synchronous serial data transmission requires a MINIMUM of two wires: clock and data. This is caused by the necessity of a separate clock to pace the serial transmission of the data. This is NOT to say that there aren't synchronous serial data transmission interfaces which require MORE than two conductions.

    It is generally viewed that asynchronous serial data can be transmitted uni-directionally (simplex), bi-directionally (duplex) or concurrently bi-directionally (full duplex) and that synchronous serial interfaces are only uni-directional, or bi-directional. There does exist a concurrently bi-directional (full duplex) facility where data input and output may be simultaneous. This is generally spoken of as the Motorola SSPI interface, or 4-wire serial interface. As its generic name states, it requires the use of four wires: clock, slave select, data input and data output. If you see mention of terms like MOSI and MISO in a serial interface you can pretty well bet you are working with a Motorola SSPI interface.

    There is a good deal more to all of this, but the information here should untangle the front end, and show why SPI ==> serial converters may be slightly complicated. So too it hopes to indicate that things like Manchester data encoding methods are just that, and not transmission methods per se. Numerous data encoding methods exist, and Manchester is but one of them.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • WhelzornWhelzorn Posts: 256
    edited 2007-10-27 04:21
    Wow, I guess there's more to this than I thought. Well for a direct link to my PC, shouldn't writing some code to interface the device to the parallel port be possible? I'm not really sure what the max data xfer rate on the parallel port is, but all I need is 115.2 kbps. I suppose that if it was faster that would be great, but 115.2 is fine. Also if it turns out that I do have to use an SX or similar for this (I'd like to avoid a prop, simply because it seems like massive overkill) that's alright too, as long as it's going to be able to copy the data from the MOSI line into the serial buffer fast enough (at least 115.2, still).

    By the way Bruce, I am indeed working with SSPI. I've got CSN (chip select), SCK (SPI Clock), MOSI, and MISO. I've actually got a couple others (IRQ and CE), but they are specific to the chip I'm using (nRF24L01).
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-10-27 06:03
    MMC access via pc parallael port:
    http://66.13.172.18/techref/mem/flash/mmc/PCppDelphi.htm

    Programming the pc parallel port for i2c and spi:
    http://michaelgellis.tripod.com/parallel.html

    These are just 2 programs I found by googling "spi pc parallel port"

    regards peter
Sign In or Register to comment.