Chapter 4
General-Purpose Counter/Timer
DAQ-STC Technical Reference Manual
4-22
©
National Instruments Corporation
The gate interrupt notifies the CPU after each counting interval so that the ISR can read the
results from the HW save register. In noncumulative mode, the ISR checks for a stale data
error, indicating that the gate action was too quick to be measured by the source clock. In this
case, the ISR ignores the counter value and writes 0 into the buffer. Once the value from the
read is stored in the buffer, the ISR checks for a rollover error and a gate acknowledge latency
error.
Use this function as an ISR for buffered event counting.
Function
Event_Counting_ISR
{
Declare variables
save_1
,
/*holds the save register value*/
g_buffer_done
;
/*indicates whether the event counting is complete*/
save_1
= Gi_HW_Save_Register;
If (noncumulative mode) then
/*check for stale data in noncumulative mode*/
{
If (Gi_Stale_Data_St is 1) then
{
/*stale data — no source transitions between two relevant gate edges*/
save_1
= 0;
}
}
If (
g_buffer_done
is 0) AND (buffer is not full) then
{
Write
save_1
into the current position in the buffer;
Increment the pointer to the current position in the buffer;
}
If (all the points have been written into the buffer) then
{
Gi_Disarm = 1;
g_buffer_done
= 1;
}
Gi_Gate_Interrupt_Ack = 1;
If (Gi_Gate_Error_St is 1) then
{
/*gate acknowledge latency error — hardware saves are too fast*/
Inform user that a gate acknowledge latency error has occurred;
Gi_Gate_Error_Confirm = 1;
}
If (Gi_TC_St is 1) then
{
/*rollover error — counter value is not correct*/
Inform user that a rollover error has occurred;
Gi_TC_Interrupt_Ack = 1;
}
}