ich wollte jetzt noch meine UART schnittstelle in betrieb nehmen, aber da
gibt es auch ein problem (siehe anderer thread). vielleicht gibt es einen
zusammenhang?

so wie es jetzt unten steht funktioniert der 8bit compare interrupt,
aber der 16er geht nicht mit

SIGNAL (SIG_OUTPUT_COMPARE1A)

und

TIMSK1 |= (1<<OCIE1A);
sei();

(Dauerreset des Controllers)



Code:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <inttypes.h>


// global vars
uint16_t ui_globalCounter = 0;
uint16_t ui_interruptCounter0 = 0;
uint16_t ui_interruptCounter1 = 0;
uint8_t  uc_timerCounter = 0;
uint8_t  uc_LEDgreen = 0;
uint8_t  uc_LEDred = 0;

#define MYF_CPU 8000000UL
#define BAUDRATE 19200UL
#define MYUBRR MYF_CPU/16/BAUDRATE-1

uint16_t ubrr = MYUBRR;

int8_t   c_incomingChar = 0;
uint8_t  uc_incomingCharNew = 0;
uint8_t	 uc_incomingCharPos = 0;

SIGNAL (SIG_OUTPUT_COMPARE0) {

    // counter then 
      //func();  //send_char!
	
}





static void initInterrupt(void) {
	
	TIMSK0 |= (1<<OCIE0A);
	sei();
}


static void initIO(void) {

	// set port b,c,d and e as output
	DDRB = 0xFF;
	DDRC = 0xFF;
	DDRD = 0xff;
	DDRE = 0xff;
	
	// clear all ports
	PORTB &= ~(1<<0);
	PORTB &= ~(1<<1);
	PORTB &= ~(1<<2);
	PORTB &= ~(1<<3);
	PORTB &= ~(1<<4);
	PORTB &= ~(1<<5);
	PORTB &= ~(1<<6);
	PORTB &= ~(1<<7);
	
	PORTC &= ~(1<<0);
	PORTC &= ~(1<<1);
	PORTC &= ~(1<<2);
	PORTC &= ~(1<<3);
	PORTC &= ~(1<<4);
	PORTC &= ~(1<<5);
	PORTC &= ~(1<<6);
	PORTC &= ~(1<<7);
	
	PORTD &= ~(1<<0);
	PORTD &= ~(1<<1);
	PORTD &= ~(1<<2);
	PORTD &= ~(1<<3);
	PORTD &= ~(1<<4);
	PORTD &= ~(1<<5);
	PORTD &= ~(1<<6);
	PORTD &= ~(1<<7);

	PORTE &= ~(1<<0);
	PORTE &= ~(1<<1);
	PORTE &= ~(1<<2);
	PORTE &= ~(1<<3);
	PORTE &= ~(1<<4);
	PORTE &= ~(1<<5);
	PORTE &= ~(1<<6);
	PORTE &= ~(1<<7);
}





static void initPWM(void) {

	// init pwm timer
	
	// 8bit timer/counter 0 
	TCCR0A = (1<<WGM00)|(1<<COM0A1)|(1<<CS01);
	// set initial pwm
	OCR0A = 200;
	
	
	// 16bit timer/counter 1
 	TCCR1A = (1<<WGM10)|(1<<COM1A1)|(1<<COM1B1);
	TCCR1B = (1<<CS10);
	// set initial pwm
	OCR1A = 200;
	OCR1B = 200;
	
	
	// 8bit timer/counter 2
	TCCR2A = (1<<WGM20)|(1<<COM2A1)|(1<<CS21);
	// set initial pwm
	OCR2A = 200;
	
	
 
}



static void initUSART(void)
{
 
    UBRRH = (uint8_t) (ubrr>>8);
    UBRRL = (uint8_t) (ubrr);
 
    // UART start receiver and transmitter 
    // data mode 8N1, asynchronous 
    UCSRB = (1 << RXEN) | (1 << TXEN);
    UCSRC = (1 << UCSZ1) | (1 << UCSZ0);

    // flush receive-buffer 
    do
    {
        UDR;
    }
    while (UCSRA & (1 << RXC));
}

static inline int sendChar (const uint8_t c)
{
    // wait for UART -> ready 
    while (!(UCSRA & (1 << UDRE)))
        ;

    // write/send char 
    UDR = c;

    return 1;
}




int main(void) {

	initIO();
	initPWM();
	initUSART();
	initInterrupt();
		
		
	while (1) {
		
		// Motorports testweise setzen
		PORTC |=   (1<<0);
		PORTC &=  ~(1<<1);
		PORTC |=   (1<<2);
		PORTC &=  ~(1<<3);
		PORTC |=   (1<<4);
		PORTC &=  ~(1<<5);
		PORTC |=   (1<<6);
		PORTC &=  ~(1<<7);
		
		
		
		
	}


return 1;


}

//eof
Gruß
RICOLA