       cbi (TIMSK2,TOIE2);              // disble Timer2 Interrupt
       tword_m=pow(2,32)*dfreq/refclk;  // calulate DDS new tuning word
       sbi (TIMSK2,TOIE2);              // enable Timer2 Interrupt 
+    }
+  }  
+ }
 
-//      Serial.print(dfreq);
-//      Serial.print("  ");
-//      Serial.println(tword_m);
-    }
-
-//   sbi(PORTD,6); // Test / set PORTD,7 high to observe timing with a scope
-//   cbi(PORTD,6); // Test /reset PORTD,7 high to observe timing with a scope
-  }
-  
- }
-//******************************************************************
+/************************************ AUDIO FUNCTIONS *******************************************************/
 // timer2 setup
 // set prscaler to 1, PWM mode to phase correct PWM,  16000000/510 = 31372.55 Hz clock
 void Setup_timer2() {

  cbi (TCCR2B, WGM22);
}

//******************************************************************
// Timer2 Interrupt Service at 31372,550 KHz = 32uSec
// this is the timebase REFCLOCK for the DDS generator
// FOUT = (M (REFCLK)) / (2 exp 32)
// runtime : 8 microseconds ( inclusive push and pop)
ISR(TIMER2_OVF_vect) {

//  sbi(PORTD,7);          // Test / set PORTD,7 high to observe timing with a oscope

  phaccu=phaccu+tword_m; // soft DDS, phase accu with 32 bits
  icnt=phaccu >> 24;     // use upper 8 bits for phase accu as frequency information

volatile unsigned long phaccu;   // pahse accumulator
volatile unsigned long tword_m;  // dds tuning word m

/************************************ SETUP *****************************************************************/
void setup()
{
  // LCD setup - uses delay() and therefore must go before any interrupts
  myGLCD.InitLCD();
  
  // Audio setup
  pinMode(AUDIOPIN, OUTPUT); // output / frequency output
  Setup_timer2();
  // disable interrupts to avoid timing distortion
  cbi (TIMSK0,TOIE0);              // disable Timer0 !!! delay() is now not available
  sbi (TIMSK2,TOIE2);              // enable Timer2 Interrupt
  dfreq=1000.0;                    // initial output frequency = 1000.o Hz
  tword_m=pow(2,32)*dfreq/refclk;  // calulate DDS new tuning word 
}

/************************************ LOOP ******************************************************************/
void loop()
{
  // LCD
  myGLCD.fillScr(VGA_RED);
  
  // Audio
  while(1) {
     if (c4ms > 250) {                 // timer / wait fou a full second
      c4ms=0;
