The Loop-Back Test
The loop-back test is a simple way to verify that your UART is working, as well
as to locate the failure point of your UART communication setup.
For example, suppose you are transmitting a signal from your microcontroller UART
through a TTL to USB converter to your laptop and it isn't working. All it takes
is one failure point for the entire system to not work, but how do you find it?
The trick is to connect the Rx to the Tx, hence the loop-back test.
For example, to verify that the UART is outputting correctly:
- connect the Rx and Tx of the UART together
- printf the letter 'A'
- have an if statement turn on a LED if 'A' is received
If it still doesn't work, you know that your code was the failure point (if not more than one failure point).
Then do this again on the PC side using HyperTerminal,
directly connecting Tx and Rx of your USB port.
And then yet again using the TTL to USB adaptor.
You get the idea . . .
I'm willing to bet that if you have a problem getting it to work, it is because your
baud rates aren't the same/synchronized.
You may also find it useful to connect your Tx line to an oscilloscope to verify
your transmitting frequency:
Top waveform: UART transmitted 0x0F
Bottom waveform: UART received 0x0F
Adding UART Functions to AVR and your $50 Robot
To add UART functionality to your $50 robot
(or any AVR based microcontroller) you need to make a few minor modifications to your code
and add a small amount of extra hardware.
Full and Half Duplex
Full Duplex is defined by the ability of a UART to simultaneously send and receive data. Half Duplex
is when a device must pause either transmitting or receiving to perform the other. A Half Duplex
UART cannot send and receive data simultaneously. While most microcontroller
UARTs are Full Duplex, most wireless transceivers are Half Duplex. This is due to the fact that
it is difficult to send two different signals at the same time under the same frequency, resulting
in data collision. If your robot is wirelessly transmitting data, in effect it will not be able to
receive commands during that transmission, assuming it is using a Half Duplex transmitter.
Please check out the step-by-step instructions on
how to add UART functionality to your $50 robot >>>.