#define __AVR_ATmega2560__ //#include #include #include #include #include //definiert den Datentyp uint8_t #include /////////////////////////////////////////////////////////////// // // Sonstige Variablen // #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif double FREQ = 20000; int LEVEL = 50; // 0 - 100 % /////////////////////////////////////////////////////////////// // // UART Variablen // #ifndef TRUE #define F_CPU 16000000UL #endif #define BAUD 115200UL /////////////////////////////////////////////////////////////// // // UART Funktionen // void initUART_RxTx(void) { UCSR0A = 0x00; UCSR0B |= ( (1 << RXEN0) | (1 << RXCIE0) | (1 << TXEN0) ); // TX, RX Interrupt einschalten UCSR0C |= ( (1 << UCSZ01) | (1 << UCSZ00) ); // 8N1 in Asynchron UBRR0H = 0; //UBRR0L = 207; //Baud 4800 bei 16 Mhz //UBRR0L = 25; //Baud 38400 bei 16 Mhz //UBRR0L = 12; //Baud 76800 bei 16 Mhz UBRR0L = 8; //Baud 115200 bei 16 Mhz } void uartPutC( char c ) //Ausgabe eines einzelnen Zeichens { while ( ! (UCSR0A & ( 1 << UDRIE0) ) ); //Abwarten bis Zeichen geschrieben wurde UDR0 = c; } void uartPutI(uint16_t integer) //Ausgabe einer 16 Bit Integerzahl { char putImessage[255]; uartPutS(itoa(integer, putImessage, 10)); } void uartPutS( const char* str ) //Ausgabe eines Strings { while ( *str ) { uartPutC( *str ); str++; } } /////////////////////////////////////////////////////////////// // // Timer Funktionen // void initPorts(void) { DDRB |= ( (1<