SPI to UART converter

Thread Starter

Daph

Joined Sep 27, 2016
1
Goal: convert SPI pins to be used as UART.

Ouestion1: In my understanding, the chip select and SCLK pin is the only diff between SPI and UART. So if I don't use CS and SCLK, can I use MOSI and MISO as TX and RX?

Ouestion2: What does an SPI to UART converter do. Why is there a need for an extra ic to accomplish this job? Does the IC max3107 do the same task?

Question3: Can I use the SPI pins as UART by writing additional software code.
 

Picbuster

Joined Dec 2, 2013
1,057
question 1 no. the mechanism is different
control: uart has control signals : cts rts dsr dtr ring indicator. data async. < no clock needed
SPI: enable clock ( data transmit receive one wire) or tx rx depending on chip used. ( some are strap selectable ) data sync clock needed.

This will answer all your questions.
However; any programmable pins at a mpu are able to be programmed and act like an UART. ( see bit banging)

Picbuster
 

MrChips

Joined Oct 2, 2009
34,628
This is an interesting request which I have not seen done before. It may not be impossible but I see three problems.

1) UART uses a protocol called NRZI (non-return to zero inverted) which is a fancy way of describing bit-banging inverted bits.
In general, UART protocol requires 10 bits when you include the START and STOP bits. SPI is usually 8-bit or 16-bit transmission. Hence you will need 16-bit mode in order to transmit the 10 bits required by UART.

2) SPI clock speeds are determined by the master SPI clock. You will have to ensure that the UART transmitted baud matches that of the receiver. You might not be able to set the SPI clock to a standard baud or you may have to set both receiver and transmitter to a non-standard baud.

3) This could work for the UART transmitter but you will have a difficult time getting the SPI receiver to detect the START bit and to clock in the serial bits at the correct baud and properly synchronized.
 
Top