All pastes #2109664 Raw Edit

Miscellany

public text v1 · immutable
#2109664 ·published 2012-02-04 12:32 UTC
rendered paste body
	#define usart_baudrate		9600L
	#define usart_bauddivider	(F_CPU / (16*usart_baudrate) - 1)
	#define usart_HI(x)		((x)>>8)
	#define usart_LO(x)		((x)& 0xFF)
	
        void
	init_usart(void){

	UBRRL = usart_LO(usart_bauddivider);
	UBRRH = usart_HI(usart_bauddivider);
	UCSRA = 0;
	UCSRB = 1<<RXEN |1<<TXEN |1<<RXCIE|0<<TXCIE|0<<UDRIE;
	UCSRC = 1<<URSEL|1<<UCSZ0|1<<UCSZ1;
	}