This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Double buffers using US_RPR and US_RCR
- From: "Eric de Jong" <list_ericdejong_10 at gmx dot net>
- To: <ecos-discuss at sources dot redhat dot com>
- Date: Mon, 27 Oct 2003 08:17:20 +0100
- Subject: Re: [ECOS] Double buffers using US_RPR and US_RCR
- References: <3F990AC5.5040306@lundinova.se>
I asume you work with an atmel arm core...
- Disable ALL interrupts before you disable the PDC (= DMA engine for the uart
on the atmel controller).
- Store the US_RPR pointer.
- Setup new transfer in buffer2
- reenable interrupts
- check US_RPR, see if it had reached the end of the buffer. if yes, your buffer
is too small, and you lost one or more characters. set an error flag.
- check if buffer2 was already processed. if not, you are about to overwrite non
processed data.
- check the time elapsed since your last swap. store the larges time for
debugging purposes.
Eric de Jong
----- Original Message -----
From: "Magnus Nilsson" <man@lundinova.se>
To: <ecos-discuss@sources.redhat.com>
Sent: Friday, October 24, 2003 12:19 PM
Subject: [ECOS] Double buffers using US_RPR and US_RCR
Hi,
I'm doing speed tests using double receive buffers and US_RPR/US_RCR.
I don't have access to any flow control, and I'm losing a byte of every
now and then, regardless of baudrate.
Presumably this happens when I receive a byte just as I'm switching buffers.
My buffer switching routine looks like this (it runs often enough not to
get any overruns):
US_RCR = 0; // disable transfer
current_chars = US_RPR - (uint32)rx_buffer_1; // see how many chars
there are in the buffer
US_RPR = (uint32)rx_buffer_2; // receive in the other buffer, as we're
going to read the first one
US_RCR = BUFFER_SIZE; // re-enable transfer
I have experimented with using:
if ((US_CSR & US_TIMEOUT) == US_TIMEOUT) {
// switch buffers
}
which greatly increased the accuracy, but I'm still losing ~1 byte every
~100kB.
Do you have any ideas on how to switch buffers without using flow control?
Kind regards/Magnus
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss