// experi8b.c

extern unsigned get_port(void);
extern int set_up_new_timer(double freq);
extern void wait(double seconds);
extern void restore_old_timer(void);

main(void)
{
  int x;
  unsigned port,da1;

  if(!(port = get_port()))
  {
    printf("No board found\n");
    exit(0);
  }

  da1 = port + 8;

  printf("This sends 0 to 255 then 254 to 1 to DAC1\n");
  printf("with a pause between each step then repeats.\n");
  printf("Both DACs have their grounds on pin 1 of header 1.\n");
  printf("DAC1's output is on pin 15 and DAC2's on pin 14.\n");
  printf("Press any key to begin, then press any key to end the test.\n\n");
  getch();

  set_up_new_timer(2000.0);

  while(!kbhit())
  {
    for(x=0; x<256; x++)
    {
      outp(da1,x);
      if(kbhit())
        break;
      wait(.025); // .025 second per step
    }

    for(x=254; x>0; x--)
    {
      outp(da1,x);
      if(kbhit())
        break;
      wait(.025); // .025 second per step
    }
  }

  restore_old_timer();
}

// end experi8b.c

