Page 1 of 2
Uart RX to 2 TX
Posted: Thu Jul 27, 2017 5:36 am
by kabouras_33
Hello to everyone,
I have been trying to find a way to receive a char from Uart Rx1 from pc (DB9 2pin) and transmit it to TX1 and TX2 but whatever I try fail if someone has any idea or lead?I am using flow code 6 and 18f46k80 pic
Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 11:45 am
by kabouras_33
Please find attached my code which i used taking as a base the flowcode example uart bridge.
I am sending a nmea simulated signal from one pc to UART RX1 and i try to tranmit it on the same time from TX2 and TX1.
In simulation it works but in reality it doesnt.
I connect all grounds together.
I would really appreciate some help because it is very frustrating not to know the code problem or hardware

Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 1:26 pm
by LeighM
Hi,
You have got both UARTs set to the same Channel (1)
Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 2:12 pm
by kabouras_33
I am really sorry i just edited without changing the channel before posting.
With correct channels it doesnt work.
I use common grounds and Rx receives and Tx1 Transmits but not Tx2
Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 3:31 pm
by LeighM
So you have your TX2 on UART Channel 2, on pins D6 and D7?
Does everything else work, LED flash, TX1?
Just TX2 not working?
Sounds like we need to look at your hardware and circuit.
Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 3:44 pm
by kabouras_33
Yes exactly.
LEDs works normally as they should.
And the simulation looks ok.
But in reality no.
I connected a DB9 plug to a serial port on my pc.from pin 3 of pc I take the transmit signal and connect it to c7 of the pic and from c6 I receive correct data but from d6 nothing.
I use internal oscillator at 20Mhz .and all ground cables are connected together but not with the pic 0v just together.
That's it....I cannot understand it!!
Ps thank you deeply for your interest and your prompt reply!!!
Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 3:52 pm
by LeighM
Hi,
That sounds like the problem then.
The signals from the D type on the PC are not 5V level, they are RS232, up to +/-12V
So you need a level convertor, such as MAX232 chip.
Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 3:53 pm
by EtsDriver
Do you have 5v level shifter in between of your pic and pc serial port? It may cause unexcepted things as RS232 on old days supplied 12V level at most and many these days supply start from +9V to even +12V on some motherboards.
EDIT: Leigh was faster!

Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 4:28 pm
by kabouras_33
Yes unfortunately I tried that yesterday and I connected a max232n with no difference!!
Re: Uart RX to 2 TX
Posted: Thu Jul 27, 2017 5:10 pm
by kabouras_33
I took the pc transmit and connect to R1in of the max232 and from R1out to c7 pic from the tx and TX2 of the pic I went to txin and TX2in respectively and from the txs out I went to a buffers 2 channels which I can monitor from another pc.
And nothing

Re: Uart RX to 2 TX
Posted: Fri Jul 28, 2017 4:56 am
by kabouras_33
I removed the pc simulator from my project and I used a GPS module I had spare and now it looks more stable the led look like everything works well.
But when I connect the GPS module tx directly to the monitor pc I can see data.When I connect to pic TX1 or TX2 no data transmit.
I am starting to thing that my programme now may have a problem probably the buffer or the type of data I receive and try to transmit.
Any thought would be highly appreciated!!

Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 5:29 am
by kabouras_33
So I am still trying with no result.
I will start from scratch,the only thing I am trying to do is take nmea data to RX and transmitter to the tx as it is with no processing.
I would appreciate some help....
Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 10:02 am
by Benj
Hello,
Having worked recently with a GSM module could it be flow control that is causing you issues? When you connect to the PC is it via a RS232 cable or via a USB to serial cable? Do you connect the flow control pins?
Another problem could be baud rate, have you checked your baud rate is correct and that your micro is running at the speed you think it is? A 1 second flasher test will help to confirm if the micro is at the right speed.
https://www.flowcode.co.uk/wikiv7/index. ... ED_flasher
Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 10:25 am
by kabouras_33
I serial directly as i have an old pc which has a serial port and connect only ground and transmit pin from pc to the ground and receive of my pic throught max232 or directly.
The baud rate is configured in both the pc and uart properties at 9600.
And a status Led which is in the programm flashes every 1 sec so i suppose its correct.
I configure the pic with external oscillator and 20Mhz pic and 8Mhz crystal with capacitors 22uf between osc1-2
What troubles me is the fact that flowcode simulation take the nmea signal and project it correctly to the lcd and probably to uart2,when i also load the programm to proteus (which i dont trust it but take out many variables like clock and supplies) it also doesnt work....
Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 10:31 am
by kabouras_33
one more think is that i tried a much simpler code which probably is wrong but in flowcode it works and in proteus and in reality the result is like the attached (same with max232 or without)
Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 10:38 am
by kabouras_33
This is what i try to achieve but through the pic so i can manipulate the transmits and receives in order to make some modes.
Now the gps module is directly connected to the virtual terminal,and its exactly the same situation that happen in reality also.

Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 11:47 am
by Benj
I think the problem is the clock source to the micrcontroller.
Are you using a crystal or resonator on your circuit? If so then what value is it?
Or are you using the internal oscillator?
Currently your chip configuration is to use a RC driven oscillator and you have your project clock speed set to 19.6608MHz so I think this could be the cause of the problem.
As mentioned above use the 1 second flasher test to get your hardware running at the right speed, Once this is right the GPS should hopefully just fall into place.
Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 1:10 pm
by kabouras_33
I have a bunch of crystal which i use but currently i tried an 8 and 10.

i just realized the configuration is wrong i should use XT,although with internal oscillator it didnt work.
When i finish work and get back home i will try the 1 sec test and inform you back!!
Once again i thank you deeply for your support and not abandon me.

Re: Uart RX to 2 TX
Posted: Wed Aug 02, 2017 2:59 pm
by Benj
Once again i thank you deeply for your support and not abandon me.
You're very welcome, just doing my job
For the 8MHz / 10MHz crystals you will need to select the HS (High Speed Crystal) oscillator option. Then set the clock speed in the project options to match e.g. 8000000. Once you have done this you can confirm with the 1 second flasher test.
with internal oscillator it didnt work
Under Tools on the Components toolbar is an INTOSC Helper component to allow you to experiment with the internal oscillator. Basically provides you with a line of C code you can add to the very start of your project to configure the micro to the right speed.
Re: Uart RX to 2 TX
Posted: Fri Aug 04, 2017 1:39 pm
by kabouras_33
First of all thanks again for the support!!!
So i tried what you told me and you were 100% right it was the oscillator problem.
With settings 8MHz HS ( low ).
I can see at last data coming through but another problem occured (as always) which now i am trying to solve.
The input is NMEA but the output is not junk but also it is not the nmea that goes in???
second is that it creates overflow and suddenly stops working.
I think that the NMEA signals that comes in are string type so i make and extremely simpe program which outputs nmea string(find attached nmea in and out).But nothing.
And pushing my luck a little further as final i try to do this (find attached nmea in and out 2)and its my final target but then absolutly nothing at all?????
Re: Uart RX to 2 TX
Posted: Fri Aug 04, 2017 2:19 pm
by LeighM
Hi,
In your second test you forgot to Initialise the RS232.
You would probably be better using ReceiveChar and SendChar in a loop,
as you will not be able to Receive a string during the time that you are sending the string.
So data from the incoming string will be missed if the time to send a string is longer than the "silent" gap between the received strings.
Re: Uart RX to 2 TX
Posted: Wed Aug 09, 2017 8:32 am
by kabouras_33
I am deeply sorry for late responce,there was a health issue.
Thanks again everyone for your great support.
So i initialised the second RS232 and change in receiving and send char in a loop but nothing for some reason no data transmit at all.
Now when i use the flowcode uart bridge example and after i fixed the clock problem after your suggestion i receive data but they are not the nmea signals i inject the receive and trnsmit timing is correct but the data change on output...
I continue the research any suggestions would be highly appreciated once again

Re: Uart RX to 2 TX
Posted: Wed Aug 09, 2017 9:54 am
by kabouras_33
Re: Uart RX to 2 TX
Posted: Wed Aug 09, 2017 11:39 am
by medelec35
Hi kabouras_33,
This post may help you?
Don't forget if you add the osccon value to set internal oscillator to say 8MHz, then you much also change the clock speed in Build, Project Options, General Options tab to match.
Martin
Re: Uart RX to 2 TX
Posted: Wed Aug 09, 2017 2:51 pm
by kabouras_33
Thank you very much for your kind reply i added the c code OSCOON=0X70; and changed clock speed 8MHz internal but still same the timing of the data transfer is correct but the data that transmits are garbage.....