/*
* SIMPLE TEST PROGRAM FOR R2R DA NETWORK
* 8 bit from PORTD( dig pin 0-7 - eq no serial port)
* PORTD is used directly due to speed
* Jens Dalsgaard Nielsen - AAU
* 
*/

void setup()
{
 // Serial.begin(9600);
 int i;
 for (i=0; i < 8; i++)
   pinMode(i,OUTPUT);
}

/*
without volatile approx 60 usec /256 but some glitches
volatile unsigned char j 150 usec for 256 loops
with arduino loop (without goto) ~ 300usec/256
Full speed with jump it takes approx 160 micro seconds for 256 steps
or 625 nano sec pr loop See image 
*/

int i=0;
volatile unsigned char j=0;
void loop()
{
  x:
  PORTD=j;
  j++;
  //if (255 < j) j = 0;
//  delayMicroseconds(10);
  goto x;
 }
