invert receive data option for soft UART

Post your requests and ideas on the future development of mikroC.
Post Reply
Author
Message
womai
Posts: 239
Joined: 16 Apr 2008 07:45

invert receive data option for soft UART

#1 Post by womai » 08 Aug 2008 17:21

The drive side can already be set to send inverted data.

I would be looking for the same on the receive side (i.e. add an additional parameter to the Soft_Uart_Init function):

Instead of

void Soft_Uart_Init(unsigned short port, unsigned short rx, unsigned short tx, unsigned short baud_rate, unsigned short inverted);

it would then be

void Soft_Uart_Init(unsigned short port, unsigned short rx, unsigned short tx, unsigned short baud_rate, unsigned short inverted_rx, unsigned short inverted_tx);

Seems simple to do... and it would enable the user to get rid of the MAX232 interface for maximum circuit simplicity.

Wolfang

idakota
Posts: 334
Joined: 27 Sep 2006 08:07
Location: Pretoria/South Africa
Contact:

#2 Post by idakota » 08 Aug 2008 20:50

You'll still need a MAX232 if you are communicating with a computer.

womai
Posts: 239
Joined: 16 Apr 2008 07:45

#3 Post by womai » 09 Aug 2008 05:06

Actually I don't - I know for sure because I have done it many times in the past - have a look at www.picaxe.co.uk and check out their download circuit. It works very well for connection to a computer.

The idea of that circuit is to use a 22kOhm resistor to limit the maximum current into the microcontroller input. The internal protection diode will then clip anything above Vcc plus one diode drop, and everything below GND minus one diode drop.

So while standard RS-232 uses voltages well above +5V and well below 0V, this simple circuit translates that into roughly 0V to 5V. On the other hand, if you send 0V to 5V, standard RS-232 has a trip point of about +2V, so again data arrives correctly. It does reduce the maximum cable length but that's not an issue for connections that are less than a few meters.

In fact, there is an application note on Microchip's website that uses the same trick - albeit with a much higher resistor value - to have a 16F microcontroller DIRECTLY measure line voltage (i.e. 220V) to get a 50 Hz reference. Not that I personally would recommend this approach in this particular case...

Wolfgang

Post Reply

Return to “mikroC Wish List”