Re: Linux serial port dropping bytes



On 2008-04-02, CBFalconer <cbfalconer@xxxxxxxxx> wrote:

So that leaves the real problem handling throughput of
approximately 1 char each 10 microsec.

You need to handle an *average* of 1 character per 10 us. But
the cost of handling each character is peanuts - even if the
UART is on a slow bus, you should be able to read out
characters at something like 20 per us. The cost is in the
handling of the interrupt itself - context switches, cache
misses, etc. That's why you use a UART with a buffer - it
takes virtually the same time to read 128 bytes out the buffer
during one interrupt, as to read 1 byte from the buffer during
the interrupt. So if you've set your UART to give an interrupt
every 100 characters, you get an interrupt every ms and read
out a block of 100 characters at a time.

That depends on your CPU speed.

True. The OP is running an XScale with Linux, so I'd guess he's
running at a couple hundred MHz.

Within the interrupt, you have to
handle something like:

REPEAT
test for more in FIFO
take one, stuff in buffer, while checking for buffer full.
test for overflow or other errors.
if any, call appropriate handler
UNTIL FIFO empty
clear interrupt system
rearm interrupt
exit

Note that some operations will require several accesses to the
UART. Those will eat up time. They will be much slower than
on-chip memory access.

People have been supporting 921K bps serial links for ages. You
do have to pay attention to what you're doing, but it's really
not that hard with a sufficiently large FIFO. However, IMO a
128 FIFO is getting close to being insufficiently large. I
wouldn't want to try to support it on a Linux system with
interrupt latencies imposed by a bunch of randomly chosen
device drivers. If it's an embedded system and you've got
control over what other ISRs are running, it should be doable.

--
Grant Edwards grante Yow! I would like to
at urinate in an OVULAR,
visi.com porcelain pool --
.



Relevant Pages

  • Re: Developing interrupt driven serial driver
    ... My next task is to make this driver codebase interrupt driven. ... deassert CTS so that the DTE would stop sending when the FIFO is full. ... interrupt handler for the receiver put the data into a larger buffer ...
    (comp.arch.embedded)
  • Re: Read full 8-bit character from serial port?
    ... This FIFO is three bytes deep. ... Thus, if the buffer is not read, the fifth character just ar- ... rived causes an overrun condition. ... with a long interrupt response time can use this mode to ...
    (comp.sys.apple2)
  • Re: Linux serial port dropping bytes
    ... UART is on a slow bus, you should be able to read out characters ... interrupt itself - context switches, cache misses, etc. That's ... why you use a UART with a buffer - it takes virtually the same ...
    (comp.arch.embedded)
  • Re: Buffer size in serial port???
    ... Thanks Valter. ... will need some help to do this - Where exactly must i change the interrupt ... Turn on follows for Installable ISR (isr16550 supporting SOFTWARE FIFO ... have a big second-level buffer. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Monitoring an 68HC908JB8 under linux
    ... I also made false steps with receiving the expected number of characters. ... has a 16 bit FIFO to avoid the loss of incoming data. ... setup the level on wich the kernal driver receives a interrupt for RX ... there are still 2 more characters to buffer in Fifo ...
    (comp.arch.embedded)