Why is IR Transceiver transmitting/receiving rubbish

infraredmicrocontrollerwireless

I am trying to interface two microcontrollers wirelessly using IR transceivers. The microcontroller I'm using is ATMega164PA running on a 3.3V supply at 8MHz and the transceiver is TFDU4101-TR3. I am using serial communication for both. When I try to send a character 10 times from one transceiver to another, I get a range of numbers between 255 and 193. Is there something that I'm doing wrong? Even if I send any other character I get the same rubbish.

Also, can I write my own protocol to establish communication between the two devices?

A schematic of my setup is shown below:

enter image description here

Best Answer

Sounds like either a baud rate mismatch or a start bit detection problem. Characters between 255 and 193 mean bits 7 and 6 are always set (0b11000000==192), as well as some lower bit (which are earlier in the serial sequence). Remarkably the receiver idles with RXD high while the transmitter should be inactive with TXD low; this combination could cause unexpected behaviour of the start bit, as the AVR transmitter will idle high. Not being familiar with the IrDA signaling standards, I would probably take an oscilloscope to the signal to examine if RXD is simply inverted from TXD.

If we do have inverted polarity behaviour, we expect a transmission like ...1111110dddddddd111111... to turn into ...111111xx0DDDDD00...0001111..., with the first 0 lost as no transmission, the 0 detected as start bit matching the least significant 1 of the transmitted byte, but the stop bit 1 would be inverted marking the framing error. At a later point, the 0 would be detected as a start bit, and eventually the transmitter times out, causing the appearance of a byte with a pattern 11...00 which does not have the frame error detected. All the data bits that are received are inverted and in the wrong position. The xes represent transmitted 0s which go undetected as the transmitter switches from not sending due to too long pulse to not sending because the value is 0. If this is the behaviour, a logic inverter on TXD should solve it.

Atmel's application note AVR1303, Use and configuration of IR communication module, covers a peripheral meant to talk to this type of transceiver. It should show what sort of signaling is normally used. By the looks of it, the format used is one pulse per 0 bit only, so direct connection to the USART is not the way to go.