|
' Check to make sure that correct number of values are passed in
If argc <> 3 Then
MsgBox "Incorrect Number of Arguments to Interpose Function
ReadFreqCounter."
ReadFreqCounter = TL_ERROR
Exit Function
Else
pinname = argv(0)
count_min = argv(1)
count_max = argv(2)
End If
' Serially read back the Frequency Counter Register counter, site by site
If theexec.Sites.SelectFirst <> loopDone Then
Do
site = theexec.Sites.SelectedSite ' get the site
' Get the frequency count for a pin at a site.
freq_count = TheHDW.Digital.FreqCtr.ReadPinSite(pinname, site)
' Get the actual flow testnumber
testnum = theexec.Sites.site(site).TestNumber
' Do test and print result (get channel number for printout)
channum = TheHDW.ChanFromPinSite(pinname, site, chIO)
If freq_count < count_min Or freq_count > count_max Then
theexec.Sites.site(site).TestResult = siteFail
Call theexec.Datalog.WriteParametricResult(site, testnum,
logTestFail, 0, pinname, channum, count_min, freq_count, count_max, 0, 0, 0, 0)
Else
theexec.Sites.site(site).TestResult = sitePass
Call theexec.Datalog.WriteParametricResult(site, testnum,
logTestPass, 0, pinname, channum, count_min, freq_count, count_max, 0, 0, 0, 0)
End If
Loop While theexec.Sites.SelectNext(loopTop) <> loopDone
End If
Exit Function
ReadFreqCounterError:
On Error GoTo 0
Call theexec.ErrorLogMessage("Function Error: ReadFreqCounter")
Call theexec.ErrorReport
ReadFreqCounter = TL_ERROR
End Function
Sample Interpose Function #3: Use to Measure Frequency on a pin
' =====================================
' Public Functions: MeasureFreq
' =====================================
'
' This function reads back the Frequency Counter register of the specified
' pin for each active site and converts the register value(s) to frequency
' using the specified vector period and specified number of cycles of the
' test. The calculated frequency is tested against the specified limits and
' the test results output to the Datalog in parametric format (i.e. with limits)
' This routine is typically included in an Functional_T interpose
' function (EndOfBodyF).
'
' Inputs:
' argv(0) = the pinname whose frequency is to be measured
' argv(1) = the tester vector period on the specified pin for this test
(seconds)
' argv(2) = the number of tester cycles during which the measurement will be
made
' argv(3) = the test lower limit (in Hz)
' argv(4) = the test upper limit (in Hz)
'
' Returns:
' The Function Fail Status (TL_SUCCESS or TL_ERROR)
'
Public Function MeasureFreq(argc As Long, argv() As String) As Integer
Dim site As Long
Dim testnum As Long
Dim freq_count As Double
Dim freq_value As Double
Dim freq_min As Double
Dim freq_max As Double
Dim prog_period As Double
Dim num_periods As Long
Dim pinname As String
Dim channum As Long
MeasureFreq = TL_SUCCESS
On Error GoTo MeasureFreqError
' Check to make sure that correct number of values are passed in
If argc <> 5 Then
MsgBox "Incorrect Number of Arguments to Interpose Function
MeasureFreq."
MeasureFreq = TL_ERROR
Exit Function
Else
pinname = argv(0)
prog_period = argv(1)
num_periods = argv(2)
freq_min = argv(3)
freq_max = argv(4)
End If
' Serially read back the Frequency Counter Register counter, site by site
If theexec.Sites.SelectFirst <> loopDone Then
Do
site = theexec.Sites.SelectedSite ' get the site
' Get the frequency count for a pin at a site.
freq_count = TheHDW.Digital.FreqCtr.ReadPinSite(pinname, site)
' Calculate frequency value from frequency count
freq_value = freq_count / (prog_period * num_periods)
' get actual flow testnumber
'testnum = tl_FlowGetTestNumber(0)
testnum = theexec.Sites.site(site).TestNumber
' Do test and print result (get channel number for printout)
channum = TheHDW.ChanFromPinSite(pinname, site, chIO)
If freq_value < freq_min Or freq_value > freq_max Then
theexec.Sites.site(site).TestResult = siteFail
'Call tl_FlowSetSiteTestResult(site, 0) ' fail
Call theexec.Datalog.WriteParametricResult(site, testnum,
logTestFail, 0, pinname, channum, freq_min, freq_value, freq_max, 0, 0, 0, 0)
Else
theexec.Sites.site(site).TestResult = sitePass
'Call tl_FlowSetSiteTestResult(site, 1) ' pass
Call theexec.Datalog.WriteParametricResult(site, testnum,
logTestPass, 0, pinname, channum, freq_min, freq_value, freq_max, 0, 0, 0, 0)
End If
Loop While theexec.Sites.SelectNext(loopTop) <> loopDone
End If
Exit Function
MeasureFreqError:
On Error GoTo 0
Call theexec.ErrorLogMessage("Function Error: MeasureFreq")
Call theexec.ErrorReport
MeasureFreq = TL_ERROR
End Function
What does my pattern file need to use frequency counter mode?
A pattern file that uses a pin in frequency counter mode requires the following
statements and use of data formats:
1. Statements:
A pin_setup statement that identifies pins as freq_count pins must be appear in
the pattern file before the vector statement and after any compiler control
statements.
Syntax
pin_setup = {pin-item freq_count ;
...
}
Where a pin-item can be:
a pin name or pin group name (defined in the pin map)
a digital channel number, from 0 to 1023
a range of digital channel numbers, in parentheses, in the form
( channel-# to channel-# )
any combination of pins and pin groups, or any combination of
channel numbers and ranges, enclosed in parentheses and separated by
commas, in the form
( item, item, ..., item )
Channels and pins cannot be intermixed in the same pattern file.
The pingroups used in the pin_setup statement may be identical to
pingroups in the vector statement pinlist, or supersets of them.
It is illegal to have a pin appear in multiple pingroups used in the
pin_setup statement.
Example:
pin_setup = { outputclkpin freq_count; }
2. Data Formats (For Ig-xl 3.20 and later)
The symbolic vector programming codes are used in special ways for frequency
counter pins. For frequency counter pins, legal data characters are 0 and X.
These datacodes do not have their normal meaning when used with frequency
counter pins. Instead, the datacodes control opening and closing the frequency
counter window, i.e. gating the pin to its frequency counter register clock.
A pair of datacodes over 2 cycles is necessary to open or close the window. The
window will open or close on the first cycle of the pair.
Before opening a frequency counter window, the datacode for that pin on all
prior cycles should be X.
To open the window for a particular pin, begin programming 0 on that pin. The
window will open the R0 edge of the first cycle programmed to 0, provided that
on the next cycle the pin is also programmed to 0. Continue programming the pin
to 0 for the number of cycles that you wish the window to be open.
To close the frequency counter window, program an X on the cycle after the one
on which the R1 edge will close the window.
This example illustrates the use of the frequency counter datacodes:
vector ($tset, FCP) {
> 1 X; // program to X on all prior vectors
> 1 0; // R0 in this cycle opens window
repeat N > 1 0; // Window stays open during repeat
> 1 0; // R1 on this cycle closes window
> 1 X; // program to X on all succeeding vectors
}
Once a pin’s value transitions from X to 0, the pattern generator looks ahead
one cycle to determine whether or not the frequency counter window should be
opened. If the next vector’s value is 0, the window will open on the R0 edge
(the open window strobe). As each cycle executes, the window will stay open as
long as the next vector’s value is 0. If the next vector’s value is X, the
window will close on edge R1 (Close window strobe).
Thus the window will remain open for approximately the number of cycles that the
pin has been programmed to 0.
For Ig-xl 3.10 and earlier:
The window opens on the R0 edge of the last vector programmed to X before a
vector programmed to 0. This will result in a count of one more than the count
would be under Ig-xl 3.20 and later. Also, because of the lookahead, under Igxl
3.10 and earlier it is highly recommended that programmers add one vector to
the pattern file after the vector with the “halt” or “end module” opcode. Make
sure this additional vector is loaded into the same memory (LVM or SVM) as the
vector with halt or end_module opcode. The additional vector will not be
executed but it should have the pin in frequency counter mode set to X. This
will prevent the pattern generator lookahead from causing the compare window to
reopen on the last vector, since the next memory location will have the pin set
to an X. This type of problem is avoided in 3.20 by having the window open on
consecutive cycles programmed to 0. |
|