Note the green part, that's the main() routine trying to do
some work, in this case I'm just pulsing a spare I/O line so I
can see what's happening. As we can see we get 5-6 pulses in before
the timer interrupts to tell us it's time for another bit to go
out the serial line.
The yellow(ish) part in the middle is the ISR deciding what bits
to stuff out the serial line (the top trace is the actual serial
output). This takes 81uS.
The two red parts are the processor entering and leaving the
interrupt. Of course this code is written in C so there is a lot
more overhead for a call than in assembler. This takes 67uS in
total, almost as long as the ISR.
Can we improve this by using the compiler's optimising options?
In AVR Studio I set the option to -Os, the maximum.
Now let's see what happens.