Chapter 4
General-Purpose Counter/Timer
DAQ-STC Technical Reference Manual
4-20
©
National Instruments Corporation
Gi_Gate_Polarity = 0 (disable inversion) or 1 (enable inversion);
Gi_Output_Mode = 1 (one clock cycle output) or 2 (toggle on TC) or 3 (toggle on TC
or gate);
Gi_Loading_On_Gate = 0;
Gi_Loading_On_TC = 0;
Gi_Gating_Mode = 1;
Gi_Gate_On_Both_Edges = 0;
Gi_Trigger_Mode_For_Edge_Gate = 2;
Gi_Stop_Mode = 0;
Gi_Counting_Once = 0;
Gi_Up_Down = 0 (down counting) or 1 (up counting);
Gi_Bank_Switch_Enable = 0;
Gi_Bank_Switch_Mode = 0;
Gi_TC_Interrupt_Enable = 0;
Gi_Gate_Interrupt_Enable = 0;
}
4.6.1.6 Buffered Event Counting
Buffered event counting is an application in which a general-purpose counter counts the edges
of its source signal. Progress of counting is observed by monitoring the counter contents, at
points of interest. This is achieved by using the HW save register and interrupts. We define
two modes of operation for this application: noncumulative mode and cumulative mode. In
noncumulative mode, the counter is reloaded every time its contents are saved due to the gate
action. In cumulative mode, the counter's contents are saved by the gate, but the counter keeps
counting.
Noncumulative mode is useful if you are interested in the number of events between two
controlling events. Cumulative mode is useful if you are interested in monitoring progress in
terms of events.
One interesting application is periodic event-count monitoring. For example, you may be
interested in the number of events that happened every second. You can do this by
programming Gi for buffered event counting and Gj for pulse generation, and then using the
Gj output as the Gi gate.
Possible error conditions are rollover, gate acknowledge latency error, and stale data error
(in noncumulative mode). Rollover is explained in section
4.4.1.1, Simple Event Counting
.
The gate acknowledge latency error occurs if the interrupt service program (ISR) does not
manage to read the value in the HW save register before the next hardware save. In
noncumulative mode, the stale data error occurs if there are two gate edges without an
intervening source edge, indicating that the gave event was too quick to be measured. In
cumulative mode, the stale data error is ignored because the gate actions do not affect the
counter contents, so that the HW save register always contains the correct value.