This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

2 devices UART with MSP430G2553

Hello all,

I am currently working on a project where I need to take data from a GPS module, send a GPS time stamp along with an ADC sample to a computer terminal to log the data.

However both the GPS and computer communicate with the MCU via UART. Now I already have the UART set up to talk to the computer at 115k baud, but I still need to UART with the GPS. I know that it is possible to implement a software UART but the examples I've found say that you must use pins tied to a timer which end up being P1.1 and P1.2 the same pins as the hardware UART already being used to talk the computer.

So naturally I thought Time-division multiplexing would be the best way to communicate with both the GPS and the computer terminal on the same 2 pins. 

This is where my knowledge begins to wain. After some basic researching I found plenty of theory on TDM but no actual way to implement it in either hardware or software. 

So wonderful engineers on the E2E forum I was wondering is there a multiplexer IC somewhere out there that could do what I want?

Or do I need to program the GPS and computer to have a "device ID" so that they both read from the same line and just stop listening if I'm not talking to it? Is either of these methods even possible or am I just chasing my tail?

  • You need a timer but you can use GPIO pins other than P1.1 and P1.2. I did a software UART using P1.5 and P1.4.

    Keep in mind all you are doing is making a pin go up or down at a certain time and detecting when a pin goes up and down.

  • So essentially software UART uses a timer interrupt to TX and a port interrupt to RX?

    Also can the hardware and software UART run simultaneously?

  • That's how I did it. Didn't run a hardware one at the same time although it should be possible. I suppose one just needs to be sure to grab things before they change or get overwritten.

  • Jon55 said:
    So essentially software UART uses a timer interrupt to TX and a port interrupt to RX?

    In simple terms, yes. You use the timer interrupt to know when to change the external TX pin state based upon the data to transmit and your software state machine that implements the soft UART.

    On the receive, you also use the timer to measure the intervals between RX pin transitions. One way is to wait for the start bit transition, then set a CCR register to fire at the appropriate baud-tick interval and check the pin, repeat for all the bits, then wait for the next start bit. It's a little more complicated than that, but the basic idea.

    Jon55 said:
    Also can the hardware and software UART run simultaneously?

    Should be able to. Depends on your CPU clock frequency and what other CPU loading you have. You mention the ADC. It just comes down to bandwidth on the CPU and internal bus.

  • Brian did put you on the right track.

    However, if you don’t need to receive data from the PC, I would use the hardware UART for the GPS (as you likely need to send data to it as well as receiving data) and make a software UART (probably with a lower baudrate than 115200) to the PC that only implements sending. Saves you the effort or writing a software UART receive.

    For sending, you can also abuse the SPI to send data to the PC.
    In this case, set-up the SPI for the proper baudrate (a bit tricky, as you can’t use modulation) and send 16 bit per byte: 0xxxxxxx-x1111111 (uh, was UART MSB first or LSB first? It probably is xxxxxxx0-1111111x then, with LSB first)
    This is sending 7 stop bits, but who cares :) At least you have your data sent with hardware support ( so 115200 are no problem) and the setup as well as the send code is simple.

**Attention** This is a public forum