Initialize counter value to zero.

This commit is contained in:
Frank Mori Hess 2007-07-11 18:26:53 +00:00
parent 1299e25cf4
commit 1a4e7fe192

View file

@ -34,6 +34,7 @@ int ni_gpct_start_simple_event_counting(comedi_t *device, unsigned subdevice)
{
int retval;
lsampl_t counter_mode;
static const unsigned initial_count = 0;
retval = reset_counter(device, subdevice);
if(retval < 0) return retval;
@ -63,6 +64,10 @@ int ni_gpct_start_simple_event_counting(comedi_t *device, unsigned subdevice)
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;