From 1a4e7fe192dba73e2eb80190dd61e245024d90fd Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Wed, 11 Jul 2007 18:26:53 +0000 Subject: [PATCH] Initialize counter value to zero. --- demo/gpct_simple_counting.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/demo/gpct_simple_counting.c b/demo/gpct_simple_counting.c index c05954a..d80cca3 100644 --- a/demo/gpct_simple_counting.c +++ b/demo/gpct_simple_counting.c @@ -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;