jnk0le / AVR-UART-lib

extremly light uart library for AVR 8 bit microcontrollers
MIT License
103 stars 36 forks source link
arduino-less avr avr-gcc avr-microcontroller avr-microcontrollers c flow-control high-speed high-throughput low-overhead optimized prematured rs232 rs485 transmission uart usart

AVR-UART-lib

An interrupt-driven USART (RS232) library for AVR microcontrollers, with support for multiple hardware UARTs, using ring buffers for receive/transmit. Designed especially for real-time or high throughput applications, with narrow resource limits.

Features

Notes

Flow control

This library provides a software implementation of CTS/RTS control lines (DTR/DSR respectively) to signal whether buffer is full (not an 80' style handshaking). It should be used, in order to achieve stable bidirectional >100kbps transmissions, especially when using non deterministic usb-serial converters (ft232, ch340 etc). The legendary "noise" that causes losing blocks of characters (not damaging) can also be fixed by that.

Config

ISR timmings (cycles)

ISR case attiny2313 atmega8 atmega328 atmega2560 lgt8f88A
TX best 37 40 40 42 30
TX worst 38 41 44 46 35
RX best 36 36 37 39 27
RX worst 40 42 43 45 32
RX rts full 41 41 44 46 32
RX rts normal 40 42 43 45 32
BUFFER_SIZE = 256 x -1 -1 -1 -1
G_SREG_SAVE -4 -4 -4 -4 -2
G_Z_SAVE -6 -6 -6 -6 -2