PDA

View Full Version : Multiple serial devices to one pic



rshaver
- 16th October 2011, 03:20
I have looked everywhere but cannot find an answer. Maybe I am using the wrong search terms. Who knows but anyway. I am building a GPS speedometer and have it working fine. For the odometer I am using a 16f88 counting pulses. This is also working fine. The speedometer is on a 16f886 connected to a 10hz gps. I guess I could put it all on one chip but I really don't want the odometer doing anything but counting miles. So if I can I would like to have the f88 send the mileage data over to the speedometer but I already have the GPS coming in via serial. Can I have 2 serial ports? Or can I use Serin2 and Hserin2 at the same time? Or should I redefine the serial every time I ask for mileage date? Or am I just over thinking this?

I humbly await advice from one of the gurus.

Ron

mackrackit
- 16th October 2011, 05:49
If your MCU has two hardware serial ports you can use both, HSERIN and HSERIN2.

If you are bit banging, SERIN2, you can use as many different pins as you want.

HenrikOlsson
- 16th October 2011, 05:55
Hi,
HSERIN2 is for the second (E)USART on PICs that have two - which the 16F886 doesn't so that's out.

SERIN or SERIN2 would work, just remember that they are both software timed commands and they are "locking" the rest of your program if you aren't using assembler interrups or DT-INTS. What it means is that if you you are using HSERIN to receive data from the GPS and SERIN(2) to recieve data from the odomter you'll be in trouble if both transmitts at the same time.

You seem to indicate though that the main PIC asks the odometer for milage data so you are in control of when it sends it. In that case I'd say that SERIN(2) would work just fine.

rshaver
- 16th October 2011, 15:34
Thank You. I have not connected the odometer pic to the speedometer yet but I did add this and the speedometer still works. hserin 250, readgps, .........
Along with: define hser_rcsta 90h
define hser_txsta 20h
define hser_baud 2400
So as soon as I build the board for the odometer I should be able to remove the lcd commands and add a hserout connect the correct pins and life should be good. I know famous last words. We shall see today I hope.

Ron