📄 cls9859evbd.cls
字号:
'Public Sub LoadData(ByVal DUTNum As Integer, ByVal Address As Integer, ByVal Data As String)
' If mvarEnabled Then
' 'Send out the data on the serial bus
' SerialLoad Address, Data
' End If
'
' If mvarAutoFUD = True Then
' 'Strobe the FUD line
' FUD_DUT1 = abvLow
' FUD_DUT1 = abvHigh
' FUD_DUT1 = abvLow
'
' 'Strobe the FUD line
' FUD_DUT2 = abvLow
' FUD_DUT2 = abvHigh
' FUD_DUT2 = abvLow
' End If
'End Sub
'Input: DutNum - DUT write data to 1,2 or Any Other Value - To write to both DUTs
'Assumes that if you are writing to both DUTs that the LSB First Bit in CFR1
'is the same for both DUTs.
Public Sub SerialLoad(ByVal DUTNum As Integer, ByVal Address As Integer, ByVal Data As String)
Dim sInstructByte As String
Dim sData As String
Dim cntr As Integer
Dim NumBytes As Integer
'Only work if the object is enabled
If mvarEnabled = True Then
'Get the number of bytes sent
NumBytes = sRegSize(Address)
'If writing to both DUTs make sure that both are in the same IOMode
If (DUTNum <> 1 And DUTNum <> 2) And (LSBFirstDUT1 <> LSBFirstDUT2) Then
'LSBFirst mode must be the same on both DUTs
MsgBox "Error: To write to both DUT's simultaniously the LSB First bit must be the same for both DUTs.", vbApplicationModal, "Error: SUB Serial Load"
Else
'If the number of bytes to send is different than the number of bytes
'present in the data passed then exit the sub
If (NumBytes = (Len(Data) / 8)) And (Address >= 0 And Address <= &HC) Then
'Build the instruction byte
sInstructByte = "0000" & cbaseDec2Bin(Address, 4)
sData = Data
'Set SCLK Low before csb goes low so that we will know its
'state
SCLK = abvLow
'Strobe the Clock_F line latching in the data
'Strobe_Clock_F
WriteEvbBuffVal evb59Buff3
'First take the CSB line low and check for LSB Frist Mode
Select Case DUTNum
Case 1
CSB_DUT1 = abvLow
'Check to see if the part is currently in LSB First Mode
If LSBFirstDUT1 Then
'Rearrange the instruction byte into LSB First format
sInstructByte = FlipString(sInstructByte)
'Rearrange the data into LSB First format
sData = FlipString(sData)
End If
Case 2
CSB_DUT2 = abvLow
'Check to see if the part is currently in LSB First Mode
If LSBFirstDUT2 Then
'Rearrange the instruction byte into LSB First format
sInstructByte = FlipString(sInstructByte)
'Rearrange the data into LSB First format
sData = FlipString(sData)
End If
Case Else
CSB_DUT1 = abvLow
CSB_DUT2 = abvLow
'Assume that DUT1 and DUT2 are set the same and check for
'LSB First mode on DUT1
If LSBFirstDUT1 Then
'Rearrange the instruction byte into LSB First format
sInstructByte = FlipString(sInstructByte)
'Rearrange the data into LSB First format
sData = FlipString(sData)
End If
End Select
'Strobe the Clock_F line latching in the CSB Lines
'Strobe_Clock_F
WriteEvbBuffVal evb59Buff3
'Build the final data string to be sent to the AD9858
sData = sInstructByte & sData
'Loop through the data
For cntr = 1 To Len(sData)
'Set SDIO to the proper value
SDIO = CInt(Mid(sData, cntr, 1))
'Take SCLK Low
SCLK = abvLow
'Strobe the Clock_F line latching in the data
' Strobe_Clock_F
WriteEvbBuffVal evb59Buff3
'Latch the data into the AD9858
SCLK = abvHigh
'Strobe the Clock_F line latching in the data
' Strobe_Clock_F
WriteEvbBuffVal evb59Buff3
'Strobe the Clock_F line latching in the data
' Strobe_Clock_F
'Take SCLK Low
' SCLK = abvLow
' WriteEvbBuffVal evb59Buff3
Next cntr
'Return SCLK Low
SCLK = abvLow
WriteEvbBuffVal evb59Buff3
'Now return the CSB line high
Select Case DUTNum
Case 1
CSB_DUT1 = abvHigh
Case 2
CSB_DUT2 = abvHigh
Case Else
CSB_DUT1 = abvHigh
CSB_DUT2 = abvHigh
End Select
'Strobe the Clock_F line latching in the CSB Lines
' Strobe_Clock_F
WriteEvbBuffVal evb59Buff3
' 'Always return SCLK to a High when done just incase the user
' SCLK = abvHigh
' 'Strobe the Clock_F line latching in the data
' Strobe_Clock_F
'Now check to see
Select Case DUTNum
Case 1
'Now Check to see if they put the part into LSB First or 2 or 3 Wire Mode
If Address = 0 Then
If Left(Right(Data, 9), 1) = "1" Then
'They sent the LSBFirst Bit
mvarLSBFirstDUT1 = True
Else
'They Sent MSB First Mode
mvarLSBFirstDUT1 = False
End If
If Left(Right(Data, 10), 1) = "1" Then
'They sent the SDIO Input Only Bit so they want 3 Wire Mode
mvarSerialIOModeDUT1 = ThreeWire
Else
'They want 2 wire mode
mvarSerialIOModeDUT1 = TwoWire
End If
End If
'Automatically do a frequency update if the option is true
If mvarAutoFUD_DUT1 = True Then
FUD_DUT1 = abvHigh
WriteEvbBuffVal evb59Buff1
FUD_DUT1 = abvLow
WriteEvbBuffVal evb59Buff1
End If
'Store the value written to the register in a buffer
sRegMapVals(0, Address) = Data
Case 2
'Now Check to see if they put the part into LSB First or 2 or 3 Wire Mode
If Address = 0 Then
If Left(Right(Data, 9), 1) = "1" Then
'They sent the LSBFirst Bit
mvarLSBFirstDUT2 = True
Else
'They Sent MSB First Mode
mvarLSBFirstDUT2 = False
End If
If Left(Right(Data, 10), 1) = "1" Then
'They sent the SDIO Input Only Bit so they want 3 Wire Mode
mvarSerialIOModeDUT2 = ThreeWire
Else
'They want 2 wire mode
mvarSerialIOModeDUT2 = TwoWire
End If
End If
'Automatically do a frequency update if the option is true
If mvarAutoFUD_DUT2 = True Then
FUD_DUT2 = abvHigh
WriteEvbBuffVal evb59Buff1
FUD_DUT2 = abvLow
WriteEvbBuffVal evb59Buff1
End If
'Store the value written to the register in a buffer
sRegMapVals(1, Address) = Data
Case Else
'Now Check to see if they put the part into LSB First or 2 or 3 Wire Mode
If Address = 0 Then
If Left(Right(Data, 9), 1) = "1" Then
'They sent the LSBFirst Bit
mvarLSBFirstDUT1 = True
mvarLSBFirstDUT2 = True
Else
'They Sent MSB First Mode
mvarLSBFirstDUT1 = False
mvarLSBFirstDUT2 = False
End If
If Left(Right(Data, 10), 1) = "1" Then
'They sent the SDIO Input Only Bit so they want 3 Wire Mode
mvarSerialIOModeDUT1 = ThreeWire
mvarSerialIOModeDUT2 = ThreeWire
Else
'They want 2 wire mode
mvarSerialIOModeDUT1 = TwoWire
mvarSerialIOModeDUT2 = TwoWire
End If
End If
If mvarAutoFUD_DUT1 And mvarAutoFUD_DUT2 Then
'Fud both at the same time
FUD_DUT1 = abvHigh
FUD_DUT2 = abvHigh
WriteEvbBuffVal evb59Buff1
FUD_DUT1 = abvLow
FUD_DUT2 = abvLow
WriteEvbBuffVal evb59Buff1
Else
'Automatically do a frequency update if the option is true
If mvarAutoFUD_DUT1 = True Then
FUD_DUT1 = abvHigh
WriteEvbBuffVal evb59Buff1
FUD_DUT1 = abvLow
WriteEvbBuffVal evb59Buff1
End If
'Automatically do a frequency update if the option is true
If mvarAutoFUD_DUT2 = True Then
FUD_DUT2 = abvHigh
WriteEvbBuffVal evb59Buff1
FUD_DUT2 = abvLow
WriteEvbBuffVal evb59Buff1
End If
End If
'Store the value written to the register in a buffer
sRegMapVals(0, Address) = Data
sRegMapVals(1, Address) = Data
End Select
Else
'The data isn't valid or the address isn't valid
If Address < 0 Or Address > &HC Then
MsgBox "Error: Invalid address = " & Address & ".", vbApplicationModal, "Error: Sub SerialLoad"
End If
If NumBytes = (Len(Data) / 8) Then
MsgBox "Error: Invalid data = " & Data & ".", vbApplicationModal, "Error: Sub SerialLoad"
End If
End If
End If
End If
End Sub
'Reads back a binary string serialy
Public Function SerialRead(ByVal DUTNum As Integer, ByVal Address As Integer, Optional ARAAR9) As String
Dim sInstructByte As String
Dim cntr As Integer
Dim NumBytes As Integer
Dim sRetStr As String
Dim OldProfile As Long
'Only work if the object is enabled
If mvarEnabled = True Then
'Get the number of bytes sent
NumBytes = sRegSize(Address)
If DUTNum = 1 Or DUTNum = 2 Then
'If the number of bytes to send is different than the number of bytes
'present in the data passed then exit the sub
If Address >= 0 And Address <= &HC Then
'If reading back from one of the RSCW use the profile pins to address
If Address >= &H7 And Address <= &HB Then
'Store the current profile setting
OldProfile = GetActiveProfile(DUTNum)
End If
'Set the proper profile for the address selected
Select Case Address
Case &H7
SetActiveProfile DUTNum, 1
Case &H8
SetActiveProfile DUTNum, 2
Case &H9
SetActiveProfile DUTNum, 3
Case &HA
'Fake out the part by addressing register 09 H because
'Register 0AH won't read back properly for some reason
If Not IsMissing(ARAAR9) Then
If ARAAR9 = 0 Then
Address = &HA 'Reading Address 0AH
Else
Address = &H9 'Reading Address 09H
End If
Else
Address = &H9 'Reading Address 09H
End If
'The profile pins actualy address the Register
SetActiveProfile DUTNum, 4
End Select
'Build the instruction byte
sInstructByte = "1000" & cbaseDec2Bin(Address, 4)
'Set SCLK high before csb goes low so that we will know its
'state
SCLK = abvHigh
WriteEvbBuffVal evb59Buff3
'Now take the appropriate the CSB line high
Select Case DUTNum
Case 1
CSB_DUT1 = abvLow
'Check to see if the part is currently in LSB First Mode
If LSBFirstDUT1 Then
'Rearrange the instruction byte into LSB First format
sInstructByte = FlipString(sInstructByte)
End If
Case 2
CSB_DUT2 = abvLow
'Check to see if the part is currently in LSB First Mode
If LSBFirstDUT2 Then
'Rearrange the instruction byte into LSB First format
sInstructByte = FlipString(sInstructByte)
End If
End Select
WriteEvbBuffVal evb59Buff3
'Take readback enable low
RB_Enable = abvLow
' WriteEvbBuffVal evb59Buff3
'Send the Instruction Byte first
For cntr = 1 To Len(sInstructByte)
'Set SDI to the proper value
SDIO = CInt(Mid(sInstructByte, cntr, 1))
'Latch the data into the AD9858
WriteEvbBuffVal evb59Buff3
' If cntr <> Len(sInstructByte) Then
'Take SCLK Low
SCLK = abvLow
'Latch the data into the AD9858
WriteEvbBuffVal evb59Buff3
' End If
'Take SCLK High
SCLK = abvHigh
'Latch the data into the AD9858
WriteEvbBuffVal evb59Buff3
Next cntr
'Now take the RB_Enable line high or low if needed
Select Case DUTNum
Case 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -