// Target : M16 // Crystal: 16.000Mhz #define F_CPU 16000000UL // Quarz mit 16Mhz #include #include #include "easy.h" #include void port_init(void) { PORTA = 0x00; DDRA = 0x00; PORTB = 0x00; DDRB = 0x00; PORTC = 0x00; DDRC = 0x00; PORTD = 0x00; DDRD = 0x00; } //UART0 initialize // desired baud rate: 9600 // actual: baud rate:9615 (0,2%) // char size: 8 bit // parity: Disabled void uart0_init(void) { UCSRB = 0x00; //disable while setting baud rate UCSRA = 0x00; UCSRC = BIT(URSEL) | 0x06; UBRRL = 0x67; //set baud rate lo UBRRH = 0x00; //set baud rate hi UCSRB = 0x98; } /* //UART0 initialize // desired baud rate: 9600 // actual: baud rate:9615 (0,2%) // char size: 8 bit // parity: Disabled void uart0_init(void) { UCSRB = (1<>8); UBRRL = (uint8_t)UART_UBRR_CALC(UART_BAUD_RATE,F_CPU); } */ #pragma interrupt_handler uart0_rx_isr:12 void uart0_rx_isr(void) { unsigned char character; character=getchar(); putchar(character); } //call this routine to initialize all peripherals void init_devices(void) { //stop errant interrupts until set up asm("cli"); //disable all interrupts port_init(); uart0_init(); MCUCR = 0x00; GICR = 0x00; TIMSK = 0x00; //timer interrupt sources asm("sei"); //re-enable interrupts //all peripherals are now initialized } //--------------------- int putchar(char c) --------------------------- // schreibt einzelnen Buchstaben auf die serielle Schnitstelle // wird von printf(...) etc genutzt. int putchar(char c) { while (!(UCSRA & (1<