Hi all, I am having to communicate with a serial device on a half-duplex link. I am in the middle of implemeting the protocol to chat with said device, and have reached the point where I have to choose the best way to ignore the echo that gets back to me every time I send something trough the UART. My answer is: I don't know ! I do have a few ideas of course, listed below, but I don't know which one actually would work best, would the most reliable, in the real world, so I am asking the pros who know this (I feel, very classical) problem inside out, to share their experience ! :-) Maybe there is a fourth option I have not even thought of ?
The options I thought of: #1 Disabling the RXD interrupt just before sending data, and re-enable it as soon as the last byte has been fully sent out. Might have to flush the receive buffer too, since it will contain the last byte sent, which I want to ignore. #2 Same as above but disable the UART Receiver altogether. Shouldn't require to flush the RX buffer since it was not active while sending. But when the Receiver will be re-enabled, will it do so "cleanly", or is there a chance the next byte I receive might be mis-read, this makes me feel uncomfortable so I prefer option #1 #3 Don't touch the receiver at all. Instead, before sending 'N' data bytes, tell the Rx ISR routine to ignore 'N' bytes, and when 'N' bytes have been skipped, start processing incoming bytes again. My favorite option would be #3 because it does not "disturb" the Receiving part (Hardware) of the UART whatsoever, doesn't make any gamble on how the UART will react exaclty. So I avoid any potential H/W problems, glitches, race conditions, strange problems what have you, that could make pull my hair again. Regards, -- Vince _______________________________________________ AVR-chat mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-chat
