Change RS232 ports with C

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Change RS232 ports with C

Post by Jan Lichtenbelt »

The RS232 Tx/Rx ports can be selected in Flowcode.

My question is , can the ports changed with a C-code ?


Kind regards

Jan Lichtenbelt

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: Change RS232 ports with C

Post by Spanish_dude »

I think Flowcode has a hardware RS232 and then a Software RS232.

INCORRECT -> If you select the software RS232 you might be able to change the pins with C code.
But if you want to change the hardware pins (if the PIC has at least two RS232 outputs) it might be difficult as you'll need to set the registers so the second RS232 of the PIC is enabled and used.

EDIT :
I just checked how Flowcode assigned a software Rx and Tx and they use defines (RS232_SW_RX or something like that) so I don't think the compiler will let you undefine and define it again in your main.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Change RS232 ports with C

Post by Benj »

Hello,

In v4 of Flowcode the RS232 component has no component connections when in hardware mode. However if you switch the coponent properties to software mode then the RX and TX component connections become available in the connections window.

Some PIC devices have RP remappable functionality which allows you to change the pins used for the hardware UART. Not many 8-bit devices have this feature built in but quite a lot of the 16-bit PICs have this.

bonjovi_ly
Posts: 3
Joined: Mon Jun 25, 2012 9:18 pm
Contact:

Re: Change RS232 ports with C

Post by bonjovi_ly »

hi

I used port c for RS232 eblock but I want change it to Port D or E it possible to do it? and how?

I used PIC16F877A with Flowcode v4

Thank you

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Change RS232 ports with C

Post by Benj »

Hello,

The 16F877A only has one hardware UART and this is fixed to PortC pins 6 and 7.

You may get away with using a software UART which can be connected to any pins but receiving data is much more reliable with a hardware UART. Transmitting data should work equally well using a hardware or software UART.

Post Reply