SPI vs. TTL serial: Could they be compatible?
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
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
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.
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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).
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