2
\$\begingroup\$

I was wondering about converting SPI to UART only in that direction, not the other way around, without using any microcontroller or bridge.

If synchronous can be seen as a particular case of asynchronous communication, wouldn't be somehow possible to make the Rx just read the input? (At least in the case it was an uninterrupted flow of bits.)

Of course, the baudrate should be matched... but are there any other limitations I'm missing?

Cheers!

\$\endgroup\$
  • \$\begingroup\$ Provided the goal is a simple bytewise conversion, this is actually a better fit for a state machine than for a stored program computer. However, MCU's are more readily available in small units of functionality than programmable logic fabric, and more people are familiar with efficiently developing for them. Things may be simplest if the output baud rate is faster than the input by more than the factor of transmitted word length over payload bits. \$\endgroup\$ – Chris Stratton Feb 10 '15 at 14:14
2
\$\begingroup\$

Yes, if the SPI bit rate matches the UART bit rate you want to generate, it can be done.

The SPI data stream needs to be carefully constructed:

  • SPI data is normally MSB-first, but UART data is normally LSB-first, so you'll need to reverse the bit order in each of the data bytes.
  • UART data contains a start bit and a stop bit bracketing each byte, so for each 8-bit data byte you want to transmit, you need to put (at least) 10 bits into the SPI data stream. One easy (but inefficient) way to do this would be to alternate data bytes with bytes of 11111110.
\$\endgroup\$
  • \$\begingroup\$ Nice! What if I cannot change the way the SPI data stream is constructed? Would it still be possible to reconstruct the information after UART? \$\endgroup\$ – Fran Feb 10 '15 at 13:07
  • 1
    \$\begingroup\$ No. If you can't change the SPI data stream, then you need to construct a SPI slave device that can interpret it as-is. By far, the easiest way to do this is to use a small microcontroller. Why are you ruling this out? \$\endgroup\$ – Dave Tweed Feb 10 '15 at 13:20
  • \$\begingroup\$ I am not allowed to modify the device that generates the SPI data stream. I was hoping to avoid the need of an additional microcontroller because of space and simplicity... but I cannot imagine other alternatives! Looks like it's gonna be a micro then! Any suggestions? It would be nice to avoid designing a board and soldering stuff, but also without using Arduino-like boards. \$\endgroup\$ – Fran Feb 10 '15 at 13:32
  • 2
    \$\begingroup\$ "I was hoping to avoid the need of an additional microcontroller because of space and simplicity.." are you saying you don't want things small and simple? Because that is what a microcontroller solution would look like. Arduino is not a microcontroller, it is a development board that contains, amongst other things, a microcontroller (and headers and connectors and voltage regulator supply and USB interface and ... . @Fran Probably an 8-pin ATtiny would be perfect for the job. \$\endgroup\$ – jippie Feb 10 '15 at 13:56
  • 1
    \$\begingroup\$ Additional constraint: the SPI data must be clocked out at exactly the right moments. For 'normal' SPI this is not a requirement, so probably a normal SPI source does not pay any attention to this. \$\endgroup\$ – Wouter van Ooijen Feb 10 '15 at 14:19
0
\$\begingroup\$

There are custom ICs for example this one from NXP: http://www.nxp.com/products/interface_and_connectivity/bridges/i2c_spi_slave_to_uart_irda_gpio_bridges/series/SC16IS740_750_760.html

They probably have an MCU hidden inside, for buffering and arbitration.

\$\endgroup\$
  • \$\begingroup\$ Thanks! I have one of those, but the device is configured using SPI and my main limitation is that the SPI is generated by a system which I cannot modify in any way. \$\endgroup\$ – Fran Feb 10 '15 at 13:10
  • \$\begingroup\$ By the way! Do you know if it would be possible to setup one of those via UART? That would solve my problem :-) \$\endgroup\$ – Fran Feb 10 '15 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.