Altera_Forum
Honored Contributor
19 years agoLoosing chars with avalon_uart
I need to use a serial line under eCos, this one being an avalon UART whose speed is fixed to 115200 bps. Design clock is 25 MHz, giving an error < 0.01 %.
When I read chars without eCos (RTOS = none), things work fine. However, if I do a similar program with eCos, I am loosing half of bytes !!! To sumarize, something like (code simplified !) :cyg_io_lookup("/dev/avalon_uart", &handle);
while (loop)
{
char data;
cyg_uint32 len = 1;
cyg_io_read(handle, &data, &len);
processChar(data);
} looses some bytes, while, without RTOS, a code like : fd = open("/dev/avalon_uart", O_RDWR | O_NONBLOCK);
while (loop)
{
char data;
int n = read(fd, &data, 1);
if (n > 0)
processChar(data);
} works fine. The test consists in sending less than 10 bytes from a PC, which is less than the capacity of the avalon driver (64 bytes). Is there something special with this API cyg_io_xxx(), which is new for me ? It looks like read() from UDP socket that discards the unread bytes of a message... An idea ? Thanks a lot...