[En-Nut-Discussion] Writting a new UART device -- I solved the problem , very weird

Don Ingram don at led.com.au
Mon Oct 21 00:22:35 CEST 2002


>The reason for using 256 byte buffers in the UART
>driver is, that the index counters will automatically
>wrap, because they are unsigned character types.
>Note that uartavr.c handles buffering inside interrupts.
>Using additional code like

>if(idx > limit) idx = 0;

>within interrupt routines degrades system performance.

If you simply increment the index and then mask off the two high bits with
an 'and', you will get a 64 byte rollover. Add the index to the base address
& voila...  works a treat, fast & easy to implement in asm in the interrupt
driver.

Cheers

Don




More information about the En-Nut-Discussion mailing list