Main Site Documentation

Panda II UART


#1

Hi,

I’ve a project which needs to utilize all 4 uarts on the panda II and also offer usb client mode in production. So I read the wiki on usb client mode and the need to switch the usb debugging mode to serial. For that I am using the rs232 shield. My question is if it is possible to somehow be able to use the uart for both debugging/transferrring code and for a uart bluetooth module?

Is this possible with conditional statements, or some other technique. Tips or sample code is appreciated. I am new to panda development and wanted to get feedback before I experiment and fry my board.

Thanks in advance.


#2

You can’t share a UART. Is there a way you can reduce the number of uarts you need, or multiplex them?

If you switched to a Domino (USBizi144), you could use a USB to Serial converter in the host port, and still retain the USB client port… If you’re going to be making your own PCB for this you could include a cheap 2 port or 4 port USB Hub controller ($1.5-5) and add a USB to Serial converter IC to give you multiple additional serial ports. In a volume of 500, this would add perhaps $6 to the project including assembly costs and PCB space…


#3

Thanks for the reply Mark. But unfortuantely we’re bound by the number of uarts needed. We chose the panda II for its low power requirements.

How would multiplexing work? Would I need another component?


#4

Have a read of this:
http://electronicdesign.com/article/digital/talk-to-multiple-devices-with-one-uart17447.aspx

The domino only uses 7ma or so more during power on state. If you disable the host port before hibernating it should use the same amount of power in hibernate too. The chips are almost identical - the LPC2388 just has a few more features than the LPC2387 (Check NXP’s site for details).

The Domino only has 3 uarts broken out, however the Rhino has the same chip just with 4 uarts broken out. If you’re doing custom PCB design you just breakout whatever you need, or have your designers do it for you :slight_smile:


#5

That was an interesting read. A few more questions.

1] If we were to enable a uart for debugging, it cannot be used for anything else?

2] Can the 2 devices gps + gprs we need be time-multiplexed as we only use them once every hour.

3] Can the usb port be switched on the fly based on certain parameters. e.g. we continue using it for debugging, but then switch it to client mode?

Any other solution besides going the domino/rhino route?


#6

I would only use a debugging UART for debugging… anything else is asking for trouble in my opinion.

If you only need to read from each device once per hour, then just use a 3:1 or 4:1 mux and use digital pins on the FEZ to control it. Then you can just select the device you want to receive from and read the serial port until you get a full, valid packet from it. If you cut one out half way through sending it shouldnt matter, as the CRC wont validate so you can just discard the packet.

If you need to send config strings to the devices, then you’ll also need a mux going the other way. Alternatively, you can just build one out of a a bunch of transistors lol. It’s not like you need anything fancy for ttl serial.

Technically you can switch the port back and forth using code, however I’d be inclined not to go down that route personally.


#7

Thanks Mark. If you don’t mind me asking, here is another question. It probably doesn’t belong in this forum.

The gps module that we’re using is the following http://www.sparkfun.com/products/9133. This unit offers uart and spi interfaces with breakouts for both. Going through the comments on the sparkfun page nobody has had luck interfacing via spi. Would it be possible to interface this gps module with the panda ii via spi. How would I wire it up? Any pointers or links are greatly appreciated.


#8

Nevermind I guess. I just read on the sparkfun forum that the spi interface can only be used for logging and not controlling the unit.


#9

Yup the SPI on any SkyTraq module is only for it to talk to a SPI flash chip to log to. The new SkyTraq Venus chip now also include I2C for logging.


#10

If I were to pre-configure the venus module, could I connect its rx to one of the digital pins and use outputcompare to read the nmea strings. If that could work could I just read them periodically instead of simulating a uart signal?


#11

it is possible to use the client USB interface for debugging and CDC serial at the same time. read the beginners guide chapter about USB client support.


#12

OutputCompare is not used for reading, but writing. Like i say, if you just want to switch between a couple of devices and get a data packet out of them very infrequently (ie: not every packet) then just use a couple of transistors or a mux.

Mike, I was figuring he was doing something like USB HID rather than CDC… if he wants serial comms + debug with the panda though, CDC with debug is perfect.


#13

Yes, I realized that after reading the tutorial on outputcompare. For usb client we were looking at implementing the mass storage mode.

But it seems like reducing the number of modules or using a multiplexer is the way to go. We still want to keep the form factor as small as possible.

Thanks again.


#14

You can use RLP to implement software UART but this can be a bad idea on high speeds. If you have something that is 9600 and not sop much data flow then you can defiantly do it in RLP. You can even do it simpler, use OC for transmit and then you only have to implement the receive side.


#15

Thanks Gus, I’m trying to interface with a venus gps module running at 4800bps. Any code examples or links?


#16

No example code as no one needed to use 4 UARTs + USB at once :slight_smile: Use the GPIO low edge interrupt to read the pin status and then you can decode the data as it comes.

Note that you can do “blocking” read very easily.

By the way, at 4800, you maybe able to implement the UART receive in C# without need for RLP!


#17

If I were to run it in a separate thread, would the blocking cause a problem? Would the other code continue to run. To explain what we’re trying to achieve is to connect a gps module (say EM408 at 4800bps) and get a position update every hour. The main code is doing something else and needs to be near real-time with no chance of getting blocked or interrupted.


#18

blocking in RLP means everything stopping. But like I said, you can use interrupts in RLP or easier use C# since it is only 4800. You only need this every hour so should be no problem.


#19

Thanks Gus. I will look around for sample code and research how to do software uart receive in c#. Would it be possible to get ideas from the softwareserial library of arduino?


#20

manavs, this this something you’ll be making more than one of or just something you’re playing with?

I’m not really a fan of bitbanging uarts, or any other protocol really unless there is absolutely no way around it. I still think you’ll find a simple MUX or even just two transistors to combine two of your uarts into one would give you all the functionality you require with by far the least effort.