why sawtooth so slow (SPI)

Hi,

used UNO and a self made DA-board and want to output a sawtooth signal triggered by an ext. interrupt.
So far it works fine, but the maximum frequency of the sawtooth signal is 200 hz and 1khz would be nice.

I generate the sawtooth simply by counting from 0 to 255 or from 255 to 0 just with a for-loop and write to the DAC in each loop.
The bit pattern for the DAC was constructed with OR and bit-shifting and i set SPI_CLOCK_DIV4, but even with SPI_CLOCK_DIV2 the maximum frequency is only 220 Hz.

What does take so much cycles that the DAC can be updated only 200 times per second. Is it the DAwrite function that takes so much cycles or is it faster with a wavetable approach? I have no idea. What's the problem?

//Interrupt service routine 0 (approach)
void saw0(void) {
		for (int level = 0; level < 255; level++) {
			DAwrite(level);
		}
		DAwrite(zero);
}

//DAC transfer function
int DAwrite(int value) {
  // *** Construct bit pattern for DAC (see datasheet AD5429) ***
  // OR controlBit with 4 times right shifted outputvalue
  int Byte1 = controlBit | (value >> 4);
  // 4 time left shift output value
  int Byte2 = value << 4;
  //enable DAC 
  digitalWrite(slaveSelectPin,LOW);
  //  send 2x8 bit pattern
  SPI.transfer(Byte1);
  SPI.transfer(Byte2);
  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin,HIGH); 
}
  digitalWrite(slaveSelectPin,LOW);

This is not the fastest function in the Arduino tool kit. You call it twice in each invocation of DAwrite. I'd have a look at PortManipulation, myself.

		for (int level = 0; level < 255; level++) {
			DAwrite(level);
		}
		DAwrite(zero);

I'd also move this loop into the DAwrite function. 510 function calls per interrupt are not speeding up your code.