0
\$\begingroup\$

In my project i need to interface a gps receiver and a gsm modem to pic16f877a, But there is only one set of UART lines in this Microcontroller. Is it possible to multiplex these two devices using software without the use of additional hardware?

\$\endgroup\$
  • 2
    \$\begingroup\$ No - but for low to medium baud rates you can do one of them in software. Or you could add hardware. \$\endgroup\$ – pjc50 Apr 5 '13 at 17:59
  • \$\begingroup\$ @pjc50 can you please elaborate the software technique. should I use two separate max232 IC's for gps and gsm? \$\endgroup\$ – Sabin Jose Apr 6 '13 at 14:42
  • \$\begingroup\$ It's commonly referred to as bit-banging and is perfectly feasible if the processor isn't too busy otherwise. I'm sure there's code examples on piclist.com or in one of the microchip app notes. Essentially you time the right sequence of 1s and 0s yourself. \$\endgroup\$ – carveone Jul 18 '13 at 22:16
  • \$\begingroup\$ Also - do you need both at the same time? If not, you could use tristate buffers to disconnect the device you aren't using. The other posts are right; there are plenty of other pics with 2 uarts. But a hack is a good way to learn :-) \$\endgroup\$ – carveone Jul 18 '13 at 22:31
2
\$\begingroup\$

You're approaching the problem in the wrong way. You have two devices that put out serial data, so you need a microcontroller with two UARTS. Luckily, such things are available, for example among the PIC24's there are chips that have two UART ports and two I2C ports. These are still PIC, so you can apply your PIC16 skills.

Match the microcontroller to the application! Do not have a "pet" microcontroller that you use for everything, no matter what.

There isn't much reason to use a PIC16 today in a new design. It's great that Microchip stands behind them and still makes them. But the primary value of this is that you can replace a nonworking one in an old device.

\$\endgroup\$
  • \$\begingroup\$ Look around. For instance, ST makes microcontrollers. Check out STM32. \$\endgroup\$ – Kaz Apr 6 '13 at 2:28
1
\$\begingroup\$

As was stated in the other answers consider switching to a more advanced PIC with 2 UART modules. The PIC18 series of microcontroller is still 8-bit, but offers more peripherals than the PIC16's. Switching to a PIC18 would also allow you to take advantage of the Microchip C18 compiler which makes writing the programs easier (can be written in C instead of Assembly) and the compiler comes with a set of software libraries, for example a software implementation of a UART peripheral.

\$\endgroup\$
  • \$\begingroup\$ Yes, it is best to use a pic with two UARTs, for example PIC18F23k22 is good. \$\endgroup\$ – Dilum Jul 19 '14 at 16:28
0
\$\begingroup\$

If you have an I2C or SPI interface available on your micro, you could hang a UART (e. g. XR20V2170IL40-F) off that.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.