Log in

View Full Version : Receiving data from more than one serial Port



PICtron
- 14th March 2005, 12:37
I have an application (16F876@20MHz) where I have to deal with more than one serial Port.

The HWUSART of the PIC is connected to some device that sends Data @9600Baud.
The PIC receives this data does some math
and logs the results to an external EEPROM.

Some of the logged data is send out on PortB.7 @ 4800Baud to
a Terminal (serial LCD) for monitoring purposes.

So far everything works fine.

Now I have got to connect a PC to a third Port @4800 Baud
to be able to read / modify / clear the log memory.

I have only two wires (besides GND) to the PC (RX & TX)

The issue is timing,
how do I get the PIC into the "communicate with PC" routine?
timewise I can't afford to sit in a SERIN2 loop and wait for a "SYNCH" character
while the MainLoop is supposed to do other tasks.

Any ideas?

Dwayne
- 14th March 2005, 19:32
Hello Jerry,

Jerry>>how do I get the PIC into the "communicate with PC" routine?
timewise I can't afford to sit in a SERIN2 loop and wait for a "SYNCH" character
while the MainLoop is supposed to do other tasks.<<

I don't know your full setup, but can you do a "on interupt" when you press the PC keyboard? then you can turn off all interputs, process your PC with your SERIN2, finsh, turn on all interputs (if that is what you are using) and return to your mainLoop.

Dwayne

languer
- 14th March 2005, 19:51
You could either poll the (software) RX pin from the PC at defined intervals, or you could use a pin with an 'interrupt-on-change (IOC)' function. Once the pin is active you can immediately jump to the SERIN/SERIN2 with a timeout (in case there is some junk on the line).

You have to take care when using the IOC function so that it does not disturbs the HSERIN, more important the other SEROUT (to LCD). If you go with the polling method, you should poll it at every tenth of a bit time (IIRC).

PICtron
- 15th March 2005, 10:20
Thanks for the replies!

I think simply polling the RX-pin will be too time consuming.

I have not used IOC yet, but I will give it a try a try, even though I would have to disable and re-enable Interrupts at many places in code to not disturb time critical tasks.