optimizing code: help avoiding modulus..

The code in reply #1 should work but all the variables used in the IRQ should be volatile.

However I would change the order of the statements a bit especially for the var n which is used as an index.
First test if it is out of range before using it.

void DAC_out()
{ 
  conta++;  //overflow should not be too much of a problem..in case change to unsigned long..
  if (conta >= pitch)
  {
    conta = 0;
    if (n >= steps) n=0;
    PORTD=out[n++];
  }
}