This is my lucky day. After working my a$$ off for a few days I finally discovered that:
-the avrgcc-compiler isn't reliable
(it doesn't do what it claims to or is supposed to do)
-the atmel datasheets have way too many fact left out
(trial and error is the only way to go)
A warning to those using interrupts: The interruptbits (in TIMSK for example) are cleared by the sei() function (or rather the processor?). So
won't work. It's gotta be the other way around.
SREG |= 0x80;
works better than sei() at times, but not always.
Then the optimization must be set to 0 at all times or you won't get what you aim for. I had the code
in an interrupt-routine, and it was optimized away by the compiler. So set the optimization to 0 or you'll regret it.
PORTC=PORTB; will give you a flashing xmas-tree but not one that looks like you thought it would.
Any opinions about this? Am I wrong?
Now I'm off to work with the ADC. Yeeha! Way to spoil a good mood.