Software UART not working

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Software UART not working

Post by Desdewit »

Hi Guys

On a Pic16f887 if you use RS232 from the hardware Port C6 &7 and it transmit & receive successfully and you change the uart to software and move tx & rx pins to Port C0 & C1 should the program still function normal with RXInt or must I change something else :?:
I need 2 x RS232 ports but can not get software uart to work with RXInt.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Software UART not working

Post by Enamul »

RXINT will work only currently with hardware USART. you can use Ben's following idea..
The software UARTs are very reliable for sending data out but not so good for receiving data. You can improve the receive functionality by using an external interrupt to synchronise the read function with the incoming start bit.

The GSM will need data to be sent and received reliably so it might be easier to use the hardware UART for the GSM and the software UART for the barcode reader. If you also enable a port change or INT interrupt in your program for the RX pin this should ensure you dont miss any incoming bytes from the barcode reader.
Enamul
University of Nottingham
enamul4mm@gmail.com

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Software UART not working

Post by Desdewit »

Enamul

Thanks for the reply; I only need the software port for sending data so this will work.
Just wasn't so sure about the RXInt.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Software UART not working

Post by Enamul »

Hi,
I am suggesting to use software USART for PC communication and RXINT using hardware usart for other one..
Do you want to have RXINT for both RS232?
Enamul
University of Nottingham
enamul4mm@gmail.com

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Software UART not working

Post by Desdewit »

Hi Enamul

I’m receiving from one & sending to another weighing Instrument so on the receiving side I'll use RXint & on the TX side I'll use software TX I just hope a 4MHz crystal will be fast enough with a 9600baud.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Software UART not working

Post by Enamul »

Yes, 4MHz is fast enough for that but 19.66MHz has 0% error in baud rate
Enamul
University of Nottingham
enamul4mm@gmail.com

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Software UART not working

Post by Desdewit »

Hi Enamul

How can I make an external interrupt for rx like Ben suggested?
You can improve the receive functionality by using an external interrupt to synchronise the read function with the incoming start bit.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Software UART not working

Post by Enamul »

Hi,
You can simply use data pin of your software RS232 as RB0/INT. If you configure RB0 INT on falling edge it will allow you to detect the start bit. In asynchronous usart communication (which RS232 uses), the start bit is sent first which is default 0 and then 8/9 bit data is sent and then stop bit. Normally data pin will be held high if no transmission in there..so whenever any transmission occurs, the data line held low for one bit-time which is start bit. So if you are waiting for falling edge in RBo iNT to trigger, you can easily know when there is a RS232 transmission. so you can receive data reliably.
Enamul
University of Nottingham
enamul4mm@gmail.com

Post Reply