⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modmain.bas

📁 AD9954源码
💻 BAS
📖 第 1 页 / 共 5 页
字号:
                                     DUT2_RAM(cntr) = RamSegment1Data(cntr1)
                             End Select
                             'Incriment the array indexer
                             cntr1 = cntr1 + 1
                         Next cntr
                    End If

                    'Load the data into the global RAMDataArrays
                    If UseRS2 Then
                        cntr1 = 0
                         For cntr = StartAddressRS2 To FinalAddressRS2
                             Select Case DUTNum
                                 Case 1:
                                     DUT1_RAM(cntr) = RamSegment2Data(cntr1)
                                 Case 2:
                                     DUT2_RAM(cntr) = RamSegment2Data(cntr1)
                                 Case Else:
                                     DUT1_RAM(cntr) = RamSegment2Data(cntr1)
                                     DUT2_RAM(cntr) = RamSegment2Data(cntr1)
                             End Select
                             'Incriment the array indexer
                             cntr1 = cntr1 + 1
                         Next cntr
                    End If

                    'Load the data into the global RAMDataArrays
                    If UseRS3 Then
                        cntr1 = 0
                         For cntr = StartAddressRS3 To FinalAddressRS3
                             Select Case DUTNum
                                 Case 1:
                                     DUT1_RAM(cntr) = RamSegment3Data(cntr1)
                                 Case 2:
                                     DUT2_RAM(cntr) = RamSegment3Data(cntr1)
                                 Case Else:
                                     DUT1_RAM(cntr) = RamSegment3Data(cntr1)
                                     DUT2_RAM(cntr) = RamSegment3Data(cntr1)
                             End Select
                             'Incriment the array indexer
                             cntr1 = cntr1 + 1
                         Next cntr
                    End If

                    'Restore the old profile
                    EvalBd.SetActiveProfile 1, TmpProfile_DUT1
                    EvalBd.SetActiveProfile 2, TmpProfile_DUT2
                Else
                    'Error message
                    MsgBox "Error: Invalid RAM File.", vbApplicationModal + vbCritical, "File Load Error!"
                End If

            Else
                'Specified File Does Not Exist
                MsgBox "Error: RAM File not found.", vbApplicationModal, "Error: SUB RAMLoadFile()"
            End If
        End If
    End If

    'Set the screen cursor to the defualt
    Screen.MousePointer = 0

    'Exit the subroutine before going into the error handler
    Exit Sub
'Handles errors
ErrorHandler:
    Select Case Err.Number
        Case 62:
            'Display an error message
            MsgBox "LOAD ERROR:  Bad RAM File, or Incomplete RAM File!", vbCritical + vbApplicationModal, "Critical File Load Error!"
            Close #FileHandle
        Case Else:
            'Display a defualt error message
            MsgBox "Subroutine: RAMLoadFile()" & vbCrLf & _
            "Error Number: " & Err.Number & vbCrLf & _
            "Description: " & Err.Description, vbCritical + vbApplicationModal, "Error Occured"
            Close #FileHandle
    End Select

    'Set the screen cursor to the defualt
    Screen.MousePointer = 0
End Sub

Public Function GetRAMFileInfo(ByVal RamFile As String) As String
    Dim FileHandle As Integer
    Dim Description As String
    Dim Dscr As String
    Dim FileRevNum As Integer
    Dim FileType As String
    Dim dummystr As String
    
    'Get a sharable file handle
    FileHandle = FreeFile(1)
    
    If RamFile <> "" Then
        If FileExists(RamFile) Then
            'Get the RAM file name
'            RamFile = File1.Path & "\" & File1.filename
            
            'Open the file
            Open RamFile For Input As #FileHandle
            
            'Read the file header back
            Input #FileHandle, FileType, FileRevNum
            'Make sure its a valid file
            If FileType = "AD9859 RAM Configuration File" Then
                'Trash the next 4 lines
                Input #FileHandle, dummystr
                Input #FileHandle, Dscr, Description
                GetRAMFileInfo = Description
            Else
                GetRAMFileInfo = "Not available!"
            End If
        Else
            GetRAMFileInfo = "No File Specified!"
        End If
    Else
        GetRAMFileInfo = "No File Specified!"
    End If
End Function

'Newer more inteligent ram dump routine
Public Sub SaveRAM2File(ByVal DUTNum As Integer, ByVal RamFile As String, ByVal sFileDescrptn As String)
    
    Dim FileHandle As Integer
    Dim dummystr As String
    Dim cntr As Integer
    Dim cntr1 As Integer
    Dim TmpProfile_DUT1 As Integer
    Dim TmpProfile_DUT2 As Integer
    Dim Packets2DownLoad As Integer

    Dim SelRamSeg As Integer
    Dim RamSegCW(0 To 3) As RSCWInfo

    Dim RamSegment0Data() As String
    Dim RamSegment1Data() As String
    Dim RamSegment2Data() As String
    Dim RamSegment3Data() As String

    Dim UseRs(0 To 3) As Boolean

    Dim UBndRSData As Integer

    Dim RSCntrStart As Integer
    Dim RSCntrStop As Integer
    Dim RSCntrStep As Integer

    Dim RAMSegAddrs(0 To 3) As Integer

    'Setup an error handler
    On Error GoTo ErrorHandler:

    RAMSegAddrs(0) = &H7
    RAMSegAddrs(1) = &H8
    RAMSegAddrs(2) = &H9
    RAMSegAddrs(3) = &HA

    'If reading from both DUTs then your about to get a nasty message, because your trying to do something that is not possible
    If (DUTNum <> 1 And DUTNum <> 2) Then
        'LSBFirst mode must be the same on both DUTs
        MsgBox "Error: You can only read from 1 DUT at a time.", vbApplicationModal, "Error: SUB RAMDumpFile()"
    Else
        'Get the active profiles
        TmpProfile_DUT1 = EvalBd.GetActiveProfile(DUTNum)

        'Get a sharable file handle
        FileHandle = FreeFile(1)

'**************** Ram Readback Start ****************
        For SelRamSeg = 0 To 3

            'Set to profile 1 to read back RSCW0
            EvalBd.SetActiveProfile DUTNum, SelRamSeg + 1
'            Delay

            'Read the data from the DUT to write the file.
            dummystr = EvalBd.SerialRead(DUTNum, RAMSegAddrs(SelRamSeg))

            'Decode the nonlogical data arangement of the RSCW Registers
            With RamSegCW(SelRamSeg)
                DecodeRSCW dummystr, .BeginAddr, .FinalAddr, .AddressRampRate, .ModeControl, .NoDwell

                'Read back the RAM Segment Data
                If .FinalAddr = .BeginAddr Then
                    Packets2DownLoad = 1
                Else
                    Packets2DownLoad = .FinalAddr - .BeginAddr + 1
                End If
                                
                'Check to see if the user has set up the ram segment control words properly
                If .BeginAddr > .FinalAddr Then
                    MsgBox "An error was found in RAM Segment Control Word #" & SelRamSeg & "." & vbCrLf & vbCrLf & "The beginning address cannot be greater than the final address.", vbCritical + vbApplicationModal, "Failed saving RAM to a file!"
                    Exit Sub
                End If
            End With

            Select Case SelRamSeg
                Case 0:
                    'Resize the RAM Segment Data buffer
                    ReDim RamSegment0Data(0 To Packets2DownLoad - 1)
                Case 1:
                    'Resize the RAM Segment Data buffer
                    ReDim RamSegment1Data(0 To Packets2DownLoad - 1)
                Case 2:
                    'Resize the RAM Segment Data buffer
                    ReDim RamSegment2Data(0 To Packets2DownLoad - 1)
                Case 3:
                    'Resize the RAM Segment Data buffer
                    ReDim RamSegment3Data(0 To Packets2DownLoad - 1)
            End Select

            'Setup the status bar
            With frmRAMLoadStatus
                .lblMsg.Caption = "Reading Ram Segment " & SelRamSeg
                .pbrProgress.Min = 1
                .pbrProgress.Max = Packets2DownLoad + 1
                .pbrProgress.value = .pbrProgress.Min
                .Refresh
            End With
            
            'Get the data from the DUT
            If EvalBd.RAMInitDownload(DUTNum) Then
                'Download the ram data
                For cntr = 1 To Packets2DownLoad
                    Select Case SelRamSeg
                        Case 0:
                            RamSegment0Data(cntr - 1) = EvalBd.RAMReadPacket(DUTNum)
                        Case 1:
                            RamSegment1Data(cntr - 1) = EvalBd.RAMReadPacket(DUTNum)
                        Case 2:
                            RamSegment2Data(cntr - 1) = EvalBd.RAMReadPacket(DUTNum)
                        Case 3:
                            RamSegment3Data(cntr - 1) = EvalBd.RAMReadPacket(DUTNum)
                    End Select
                    
                    'Update the status bar
                    frmRAMLoadStatus.pbrProgress.value = cntr
                    frmRAMLoadStatus.pbrProgress.Refresh
                Next cntr
                
                'Terminate the memory dump
                EvalBd.RAMTerminateDownload DUTNum
                
                'Update the status bar
                frmRAMLoadStatus.pbrProgress.value = frmRAMLoadStatus.pbrProgress.Max
                frmRAMLoadStatus.pbrProgress.Refresh
            Else
                'RAM Segment 1 Download failed
                MsgBox "Specifiy one DUT only.  RAM Readback failed", vbApplicationModal + vbCritical, "Error: RAMDumpFile"
                Exit Sub
            End If

        Next SelRamSeg
'**************** Ram Readback Finished ****************

'********* Now Start Writing the data to the file ********************
        'Open the file
        Open RamFile For Output As #FileHandle

        'Write the file header back
        Write #FileHandle, "AD9859 RAM Configuration File", 1#

        'Write a spacer
        Write #FileHandle, ""
        'Write description
        Write #FileHandle, "Description", sFileDescrptn

        'First assume that we will use all of the ram segments
        UseRs(0) = True
        UseRs(1) = True
        UseRs(2) = True
        UseRs(3) = True

        'Now check each one to see if it exists in another ram segment and if so
        'mark it as unused
        For SelRamSeg = 0 To 3
            For cntr1 = 0 To 3
                'Dont even check the ram segment against it's self
                If SelRamSeg <> cntr1 And UseRs(cntr1) Then
                    'Check each Ram Segment but don't check aginst itself
                    If RamSegCW(SelRamSeg).BeginAddr >= RamSegCW(cntr1).BeginAddr Then
                        If RamSegCW(SelRamSeg).FinalAddr <= RamSegCW(cntr1).FinalAddr Then
                            'Uses the same ram segment area mark it as unused
                            UseRs(SelRamSeg) = False
                        End If
                    End If
                End If
            Next
        Next SelRamSeg

        For SelRamSeg = 0 To 3
            'Write a spacer
            Write #FileHandle, ""
            'Write BEGIN - RAM Segmen

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -