building a software UART

ok brainy low level c guys.
     how difficult is it to write a software uart, as opposed to adding an actual Hardware UART to my board? and what are the typical first timer mistakes i need to look out for?
bythefshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

griesshCommented:
Hi bythefsh,

A UART is the chip that actually converts a serial bit stream into a byte values. It will scan input ports according to a defined baud rate, check for framing information and may have to deal with handshake lines. This is done for incoming and outgoing information.

Now I am not sure what hardware you are on, but dealing with serial I/O on that level might take up quite some resources fro your CPU.


======
Werner
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
grg99Commented:
I wouldnt recommend a software UART, especially if the CPU has any other real-time things to respond to.

If you must, the most efficient way is to set up a timer interrupt at 16x the baud rate, then on each interrupt you can check to see if the start bit has begun.  Then skip 8 counts and sample again, you shoul dnow be in the middle of the start bit.  Then skip 16 counts and sample the 8 bits every 16 counts.  then check for the stop bit.  Not too hard if you're used to interrupt routines.

That's for receiving, for sending you just do the opposite, send one bit at each timer interrupt.
0
Jaime OlivaresSoftware ArchitectCommented:
Feasibility will depend on Platform & Operating System.
If you are working with a Windows/Intel OS/Platform, then will be a little hard to ensure proper timing because windows does some task simultaneously that can consume system resources avoiding you to transmit in proper time.
If you are working with a non-multitasking operating system like DOS, this could be done succefully using many techniques, polled or interrupted, as proposed by grg99.
If you are working with a microcontroller, it could be done also without problems, there are many ways to do it and is very popular in PicMicro microcontrollers, because most of them didn't use to have a real UART.
But notice that, depending on technique choosen you will be able or not to do full-duplex communication.

Please specify Platform and OS.

Good luck,
Jaime.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Components

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.