Multiple serial devices to one pic


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2007
    Posts
    11

    Default Multiple serial devices to one pic

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: Multiple serial devices to one pic

    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.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,294

    Default Re: Multiple serial devices to one pic

    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.

  4. #4
    Join Date
    Jun 2007
    Posts
    11

    Default Re: Multiple serial devices to one pic

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts