Problem with uart timing

Hi,

I use the uart for communicating with other devices.

The device sends a few bytes to the wismo quick 2400 modem and the modem answers with a few response bytes. It is very important for us that the response is in 10 msec.

Now I wrote a very simple program that echoes every byte I send to the modem. I tried it with different baud rates and got the following results:

Time between tx and rx byte
115200 baud 500 usec
1200 baud 35 msec

We must use 1200 baud because the device talks only at that baudrate.
But the response time is much to long.

And now the question: Why differs the response time at different baud rates??

Thanks beforehand!

Til

Hi Til,

I don’t think you can expect the answer within 10msec at 1200 baud. Correct me if I’m wrong but if you use 8 bit, you need to transmit 11 bits including start/stop/parity… even if you setup 1200 8N1, I think still 11 bits are used for 1 byte. So at 1200 baud it takes about 9.2 msec for one byte to get to the wavecom modem. And another 9.2 to get the answer back. So you should at least have a roundtrip time of 18 msec per Byte if sent seperately!

Best Regards,
Jan

ok, i am sorry, i must explain it in more detail words

I do not want to get the whole answer within 10 msec. Only the beginning of the answer(the 1st byte) must be within 10 msec.

I tried another little program that sets a portpin in the uart handler. The time in the table below is the time between the end of a tx byte to the modem and the rising edge of the portpin (the portping is low before).

1.2 msec bei 115200 baud
1.7 msec bei 57800 baud
2.0 msec bei 38400 baud
3.0 msec bei 19200 baud
5.0 msec bei 9600 baud
9.0 msec bei 4800 baud
17.0 msec bei 2400 baud
34.0 msec bei 1200 baud

Hi Til,

how many bytes did you send to this program right after each other?
Did you send just a single byte, or a few bytes?

Your UART handler is called with a number of bytes that have been received. Does this number equal 1? I know that the operating system will group bytes received shortly after each other into packages. It will then call your handler with more than 1 byte at a time (if there have been received a few bytes).

I guess they have a timeout so when it is exceeded the system will send the data to the application. From your measurements I would further assume that this timeout is related to the port speed. So for example if nothing has been received in the time it would take to receive 5 bytes, then the UART handler will be called.

Since there is the operating system that facilitates all the nice features of OpenAT, you don’t have the full control of the hardware… And I am pretty sure that there is no way to speed this up… And it’s not even guaranteed that all versions of OpenAT will have the exact same timing!

Best Regards,
Jan

Is it fair to say that the ‘DataHandler’ callback when using a UARTx is somewhat spontaneous? Or, is there some way to configure the time-out of the UARTx?

Hi wavelet,

I haven’t seen a way to set timeouts, and I guess depending what other operations are performed by the application or the OS, you might experience slight delays. I would assume that it would not matter to much, but if you are waiting for certain data to arrive, you could always start a timer and when that expires check if the data is there…

Best Regards,
Jan

Hello jan,

That makes sense, but I am more concerned with an external peripheral that might not meet the time-out requirements of the UARTx driver. This would cause broken messages.

Well hopefuly I wont have to deal with it, and will continue on with the magic of OAT!