HOW TO USE FREQUENCY COUNTER MODE ON THE J750 Last update by Daniel Murphy 3/22/99 What is Frequency Counter Mode? Frequency Counter Mode is a pin setup on the J750 that allows the programmer to count transitions on the specified pin. When a digital channel is in frequency counter mode, its comparator output is gated to the positive edge triggered clock input on the 16-bit frequency counter register associated with that channel. Thus positive transitions on the specified pin cause the frequency counter register to be incremented. The contents of frequency counter registers may be cleared or read by an application program. Reading a frequency counter register returns a 2’s complement number (range –32768 to +32767). Negative values occur when the count surpasses 32767. To convert a negative number to a positive value, add 65536 to it. What are the restrictions on a test that uses Frequency Counter Mode? 1. The timing sheet used (Edge Set or Time Set Basic) must be in Extended Mode. 2. The timing sheet must set the mode of the pin that will do frequency counting by selecting “freq_counter” in the Pin/Group Setup column. 3. The timing sheet must set the Compare Mode column of the pin to Window. 4. The pattern file must contain a “pin_setup freq_counter” statement specifying the pins or channels that are in frequency counter mode. The pattern will use the symbolic data characters 0 and X to open and close the frequency counter window. See the description of frequency counter data below. 5. The program should clear the frequency counter register prior to executing the test and read back the value in the register at the conclusion of the test. How do I clear or read a channel’s frequency counter register in a test? As of this writing there are four functions in the J750 Visual Basic for Test API (Application Program Interface) which may be called by a program to access the Frequency Counter registers. They are described below as well as in the VB for Test help: TheHdw.Digital.FreqCtr.Method where Method is one of the following: 1. ClearChan: This function clears the frequency count for a channel. Syntax TheHdw.Digital.FreqCtr.ClearChan(ByVal DigChanNum As Long) Where DigChanNum = The number of a digital channel. 2. ClearPinSite: Clear the frequency count for a pin at a site. Syntax TheHdw.Digital.FreqCtr.ClearPinSite(pinName As String, ByVal Site As Integer) Where PinName = The name of a digital pin. Site = The number of a site. 3. ReadChan: Return the frequency count for a channel. Syntax TheHdw.Digital.FreqCtr.ReadChan(ByVal DigChanNum) As Integer Where DigChanNum = The number of a digital channel. 4. ReadPinSite: Return the frequency count for a pin at a site. Syntax TheHdw.Digital.FreqCtr.ReadPinSite(pinName As String, ByVal Site) As Integer Where PinName = The name of a single digital pin. Site = The number of a site. You may construct your own interpose functions using these API calls. For reference, the next section has three, well documented sample Interpose functions. The first, “ClearFreqCounter”, is for clearing a specified pin’s frequency counter register, site by site. The second, “ReadFreqCounter”, will read a pin’s Frequency Counter Register, site by site, and compare the values to specified limits. The third, “MeasureFreq”, will read a pin’s Frequency Counter Register, site by site, convert the values to frequency, and compare each calculated frequency to specified limits. Sample Interpose Function #1: Use to a pin’s Clear Frequency Counter Register Option Explicit ' ================================== ' Public Functions: ClearFreqCounter ' ================================== ' ' This function clears the Frequency Counter for each active site. ' This routine is typically included in an Functional_T interpose ' function (StartOfBodyF). ' ' Inputs: ' argv(0) = the pinname whose frequency counter register is to be cleared ' ' Returns: ' The Function Fail Status (TL_SUCCESS or TL_ERROR) ' Public Function ClearFreqCounter(argc As Long, argv() As String) As Long Dim site As Long Dim pinname As String ClearFreqCounter = TL_SUCCESS On Error GoTo ClearFreqCounterError ' Check to make sure that correct number of values are passed in If argc <> 1 Then MsgBox "Interpose function ClearFreqCounter requires a Pin Name as a Parameter" ClearFreqCounter = TL_ERROR Exit Function Else pinname = argv(0) End If ' Serially Clear Frequency Counter by Site If theexec.Sites.SelectFirst <> loopDone Then Do site = theexec.Sites.SelectedSite ' get the site ' clear frequency count Call TheHDW.Digital.FreqCtr.ClearPinSite(pinname, site) Loop While theexec.Sites.SelectNext(loopTop) <> loopDone End If Exit Function ClearFreqCounterError: On Error GoTo 0 Call theexec.ErrorLogMessage("Function Error: ClearFreqCounter") Call theexec.ErrorReport ClearFreqCounter = TL_ERROR End Function Sample Interpose Function #2: Use to Read Frequency Counter Register ' ===================================== ' Public Functions: ReadFreqCounter ' ===================================== ' ' This function reads back the Frequency Counter register of the specified ' pin for each active site and compares the value to specified limits. The test ' results will be 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 test lower limit (in counts) ' argv(2) = the test upper limit (in counts) ' ' Returns: ' The Function Fail Status (TL_SUCCESS or TL_ERROR) ' Public Function ReadFreqCounter(argc As Long, argv() As String) As Integer Dim site As Long Dim testnum As Long Dim freq_count As Double Dim count_min As Double Dim count_max As Double Dim pinname As String Dim channum As Long ReadFreqCounter = TL_SUCCESS On Error GoTo ReadFreqCounterError 作者: 半仙 时间: 2009-7-26 19:45
' 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. 作者: ictest 时间: 2009-7-26 20:12