Page 1 of 1

RS232 Inverse Polarity

Posted: Wed Mar 07, 2012 2:20 pm
by Raph
Hi guys,

I've searched for a way to set up flowcode (V5) to inverse the communication signal of the RS232, but didn't find a solution.

I'm using the software RS232 on a PIC18F2520 @ 2400bps, Tx on RC0 (pin11) and Rx on RC1 (pin12).

So I was wondering if anyone know how to set flowcode (or in C so i can add a C block) to have an inverted RS232 signal.

Have a nice day
Keep coding ;)

Raph

EDIT :
I've found that I apparently need to modify the BAUDCON Register, especially the bit 4 (TXCKP, set it to "1" to inverse polarity). I've look in the C code generated by flowcode and the settings but I didn't find anything regarding this bit or register. Anyone know how can I do this in flowcode (or in a C block) ?

Re: RS232 Inverse Polarity

Posted: Fri Mar 09, 2012 12:55 pm
by DavidA
Hi Raph,

While im not sure how to do this myself, I would imagine you might be able to customise the C-code behind the component, to do this right-click on the component in the panel and select "Custom Code".

Re: RS232 Inverse Polarity

Posted: Fri Mar 09, 2012 1:28 pm
by Steve
I've had a quick look at the datasheet and bit 4 of that register is the "Synchronous Clock Polarity Select bit". I don't think this does what you are asking. You may need to invert the signals in hardware.

Re: RS232 Inverse Polarity

Posted: Fri Mar 09, 2012 1:32 pm
by Benj
Hello,

If you are connecting the microcontroller's UART to a RS232 bus then a logic converter such as a MAX232 will automatically inverse the signals for you as well as convert the voltage levels to +/-12V.

Re: RS232 Inverse Polarity

Posted: Mon Mar 12, 2012 11:20 am
by Raph
Hi,

Thanks for all your answers.
Benj wrote: If you are connecting the microcontroller's UART to a RS232 bus then a logic converter such as a MAX232 will automatically inverse the signals for you as well as convert the voltage levels to +/-12V.
I use a MAX232 with the hardware UART (to a PC) and it works perfectly, but with the software RS232 I don't need to convert from 5V to 12V so I was wondering if I could inverse the signal directly in the PIC (I know it's possible with the BASIC Stamp).
DavidA wrote: While im not sure how to do this myself, I would imagine you might be able to customise the C-code behind the component, to do this right-click on the component in the panel and select "Custom Code".
I think I'll try to modify the Custom Code and see if I can acheive my goal that way (I ll post here the solution if it works) otherwise I add a MAX232 to do the job in hardware.

Thanks to all of you for your answers and your time

Raph

Re: RS232 Inverse Polarity

Posted: Mon Mar 12, 2012 11:35 am
by Benj
Hello Raph,

If your just using a serial signal chip to chip then you shouldn't have to manually inverse the polarity unless the other device is specifically expecting the inverse polarity.

Re: RS232 Inverse Polarity

Posted: Mon Mar 12, 2012 5:15 pm
by Raph
Hello Benj,

That's exactly what the other device want, inverted polarity. I know because I can comunicate with it nicely using an inverted polarity RS232 signal (with a BASIC Stamp). But I would love to move on and use a PIC which is much more faster and with more memory.

Re: RS232 Inverse Polarity

Posted: Mon Mar 12, 2012 5:29 pm
by Benj
Hello,

The easy way would be to use a logic chip like a 74LS04 inverter to switch the polarity of the signal. This would then work for both the send and receive without having to modify any code.

The hard way would be to dig down into the Flowcode software UART code and flip the polarity of all the I/O functionality.

What you require is not a standard recognised method for asynchronous serial data and this is why this mode of operation is not supported directly in Flowcode or on the UART peripherals on the PICs. Seems strange that BasicStamp have adopted this approach.