Anders,
I did some testing here on my end w/ a typical MBED -> USB -> PC setup. I put together an app to send bytes from the MBED at (115200 * 8) = 921600 baud and receive them on the PC (in python using pyserial). I send bursts of 10,000 packets with one second in between. One packet consists of the following 7 bytes:
<MARKER BYTE> <4 BYTE TIME STAMP> <CHECKSUM BYTE> <MARKER BYTE>
It is possible that if the marker byte appears in the data of the time stamp, it will be escaped so as not to confuse the actual marker byte start/stop packet framing...
Anyway, I too get some checksum errors when transmitting at 921600 baud. They seem to come in short bursts, but the system just drops those bad checksum packets and recovers shortly after. I've been able to send over 50k packets without any dropped packets though... Interestingly, even at 115200 it seems like it is possible to get a few bad packets as well.
This probably isn't the best test to really debug what the problem is here. As I just wrote my framing packet code today, it likely has some errors and non-handled exceptions. Here is my idea for now to figure out where the problem may be:
Write a debug program that sends a known byte series and expectes that same series to be echo'd back. a good example is from this app: SerialBuffered and then try:
1) Write a PC program that simply echo's bytes back on the /dev/ttyACM0 and run the test at various baud rates
2) Try the same thing but using a very short jumper between local hardware uart RX/TX pins
Here are my theories on how these experiements might work out:
A) If the test succeeds on both #1 and #2, then there isn't really a problem! Magic! :)
B) If the test fails on both #1 and #2, but only at some (e.g. higher) baud rates then the problem should be something with the LCP1768 not supporting that baud rate due to the clock rate and divisor (refer to manual), how the serial putc has been implemented (not making use of the hardware DMA), or at least a problem specific to the MBED chip itself and not your PC.
C) If the test fails on only #1, but secceeds on #2, then the problem points to the USB->Serial link or to the PC. The secret serial->USB chip on the bottom of the MBED maybe doesn't support those higher rates. The driver for the PC's Virtual Com port maybe doesn't support higher rates or has some interrupt servicing issues like you considered. The PC code should be written in native C and not in python ;p heh... Finally maybe there is just too much noise somewhere, between the LCP1768 and the secret chip, or from the USB connectors, etc...
Just some ideas, but I haven't written the test code yet... Lemme know if you get around to this before me, as I will likely need to use higher baud rates some day and would prefer closer to 100% link quality as opposed to the ~90% or so that I got in a handfull of very rough tests...
-john
When I began losing characters even on my reliable Ubuntu, I digged into the UART and USB litterature (I'm unfortunately not much of an expert here...) and when I looked at the Serial class as well as the LPC1768 manual I saw no signs of flow-control.
If the communication is only based on UART0 I don't see how the MBED control chip can know if the LPC1768 is ready and vice versa.
What am I missing?
Regards,
Anders