{
int retval;
lsampl_t counter_mode;
+ static const unsigned initial_count = 0;
retval = reset_counter(device, subdevice);
if(retval < 0) return retval;
retval = set_counter_mode(device, subdevice, counter_mode);
if(retval < 0) return retval;
+ /* set initial counter value by writing to channel 0. The "load a" and "load b" registers can be
+ set by writing to channels 1 and 2 respectively. */
+ retval = comedi_data_write(device, subdevice, 0, 0, 0, initial_count);
+
retval = arm(device, subdevice, NI_GPCT_ARM_IMMEDIATE);
if(retval < 0) return retval;