The problem is that in your code you are using the wrong application type. You are using GPCTR_Set_Application (iDevice, ND_COUNTER_1, ND_SIMPLE_EVENT_CNT but you should use GPCTR_Set_Application (iDevice, ND_COUNTER_1, ND_BUFFERED_EVENT_CNT) and therefore you have to add a line which configures the size of the buffer with GPCTR_Config_Buffer (iDevice, ND_COUNTER_1, 0, 1000, buffer_1) which is able to store 1000 values in it's buffer. This makes sure that every time an leading edge occurs at the GATE of counter 1 it transfers the counter value into the buffer. If you setup counter 0 for the 100Hz gating signal you are able to have access to this signal from counter 0 with the function call GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_GATE, ND_OTHER_GPCTR_OUTPUT) but if you want to use this signal as well as Gate input for counter 2 than you have to hardwire the output of counter 0 to the Gate of counter 2 and use the GPCTR_Change_Parameter (iDevice, ND_COUNTER_2, ND_GATE, ND_PFI_30) function to indicate that the Gate signal is applied at the PFI pin.
So your program should look like (when only counter 1 is used):
GPCTR_Control(iDevice, ND_COUNTER_0, ND_RESET);
GPCTR_Set_Application(iDevice, ND_COUNTER_0,ND_PULSE_TRAIN_GNR);
GPCTR_Change_Parameter(iDevice, ND_COUNTER_0, ND_SOURCE,ND_INTERNAL_100_KHZ);
GPCTR_Change_Parameter(iDevice, ND_COUNTER_0, ND_COUNT_1,ulLOWcount);
GPCTR_Change_Parameter(iDevice, ND_COUNTER_0, ND_COUNT_2,ulHIGHcount);
Select_Signal(iDevice, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT,ND_LOW_TO_HIGH);
GPCTR_Control(iDevice, ND_COUNTER_0, ND_PROGRAM);
printf(" Frequency squarewave generation started...\n");
GPCTR_Control(iDevice, ND_COUNTER_1, ND_RESET);
/*GPCTR_Set_Application (iDevice, ND_COUNTER_1, ND_SIMPLE_EVENT_CNT); must be changed to */
GPCTR_Set_Application (iDevice, ND_COUNTER_1, ND_BUFFERED_EVENT_CNT);
/* must be added to configure the buffer which stores the values */
GPCTR_Config_Buffer (iDevice, ND_COUNTER_1, 0, 1000, buffer_1);
GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_SOURCE,ND_PFI_35);
GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_GATE, ND_OTHER_GPCTR_OUTPUT);
GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_INITIAL_COUNT, 0);
GPCTR_Control(iDevice, ND_COUNTER_1, ND_PROGRAM);
do {
GPCTR_Watch(iDevice, ND_COUNTER_1, ND_ARMED,&counter_armed);
} while(counter_armed != ND_NO);
GPCTR_Watch (iDevice, ND_COUNTER_1, ND_COUNT, &counter_value);
printf("The counter value is %i.\n",counter_value);
GPCTR_Control(iDevice, ND_COUNTER_0, ND_RESET);
GPCTR_Control(iDevice, ND_COUNTER_1, ND_RESET);
Regards,
Heinrich Illig
National Instruments