     c4ms++;
     icnt1=0;
    }   
-
-// cbi(PORTD,7);            // reset PORTD,7
 }

      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
  }
  
 }
//******************************************************************
// timer2 setup
// set prscaler to 1, PWM mode to phase correct PWM,  16000000/510 = 31372.55 Hz clock
void Setup_timer2() {

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;
