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

📄 dlgsfr.frm

📁 CH372调试程序,软件代码及编译好的执行程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Width           =   945
      End
   End
   Begin VB.Label m_ver 
      AutoSize        =   -1  'True
      Caption         =   "??"
      Height          =   180
      Left            =   1920
      TabIndex        =   1
      Top             =   577
      Width           =   180
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "固件程序版本"
      Height          =   180
      Left            =   570
      TabIndex        =   0
      Top             =   577
      Width           =   1080
   End
End
Attribute VB_Name = "DLGSFR"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Old As String
Public Function mWriteSFR(Add As Long, value As String) As Boolean
    Dim C As Byte
    If (value = "") Then
        mWriteSFR = True
        Exit Function
    End If
    C = hextobcd(value)
    If (CH375DBG_WriteSFR(Add, C) = True) Then
         mWriteSFR = True
    Else
         mWriteSFR = False
    End If
End Function

Private Sub Command1_Click()
    Dim ver As Byte
    Dim val1 As Byte
    Dim val2 As Byte
    Dim val3 As Byte
    Dim val4 As Byte
    Dim val5 As Byte
    Dim val6 As Byte
    Dim val7 As Byte
    Dim val8 As Byte
    Dim val9 As Byte
    Dim val10 As Byte
    Dim val11 As Byte
    Dim val12 As Byte
    Dim val13 As Byte
    Dim val14 As Byte
    Dim val15 As Byte
    Dim val16 As Byte
    
    If (CH375DBG_GetFirmwareInfo(ver) = True) Then
        m_ver.Caption = hex2bit(ver)
    Else
        MsgBox "无法打开CH372/CH375,可能未工作或者单片机未执行调试程序", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H80, val1) = True) Then
        Text2(1).Text = hex2bit(val1)
    Else
        MsgBox "SFR读地址P0失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H87, val2) = True) Then
       Text2(2).Text = hex2bit(val2)
    Else
        MsgBox "SFR读地址PCON失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H88, val3) = True) Then
        Text2(3).Text = hex2bit(val3)
    Else
        MsgBox "SFR读地址TCON失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H89, val4) = True) Then
        Text2(4).Text = hex2bit(val4)
    Else
        MsgBox "SFR读地址TMOD失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H8A, val5) = True) Then
        Text2(5).Text = hex2bit(val5)
    Else
        MsgBox "SFR读地址TL0失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H8B, val6) = True) Then
        Text2(6).Text = hex2bit(val6)
    Else
        MsgBox "SFR读地址TL1失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H8C, val7) = True) Then
       Text2(7).Text = hex2bit(val7)
    Else
        MsgBox "SFR读地址TH0失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H8D, val8) = True) Then
       Text2(8).Text = hex2bit(val8)
    Else
        MsgBox "SFR读地址TH1失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H90, val9) = True) Then
       Text2(9).Text = hex2bit(val9)
    Else
        MsgBox "SFR读地址P1失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H98, val10) = True) Then
        Text2(10).Text = hex2bit(val10)
    Else
        MsgBox "SFR读地址SCON失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&H99, val11) = True) Then
        Text2(11).Text = hex2bit(val11)
    Else
        MsgBox "SFR读地址SBUF失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&HA0, val12) = True) Then
       Text2(12).Text = hex2bit(val12)
    Else
        MsgBox "SFR读地址P2失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&HA8, val13) = True) Then
       Text2(13).Text = hex2bit(val13)
    Else
        MsgBox "SFR读地址IE失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&HB0, val14) = True) Then
       Text2(14).Text = hex2bit(val14)
    Else
        MsgBox "SFR读地址P3失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&HB8, val15) = True) Then
        Text2(15).Text = hex2bit(val15)
    Else
        MsgBox "SFR读地址IP失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
    If (CH375DBG_ReadSFR(&HC8, val16) = True) Then
        Text2(16).Text = hex2bit(val16)
    Else
        MsgBox "SFR读地址T2CON失败", vbOKCancel, "CH37XDBG"
        Exit Sub
    End If
End Sub

Private Sub Form_Load()
    Dim Wndcla As WNDCLASS
    Dim param As Byte
    Dim hw As Long
    Dim cli As CLIENTCREATESTRUCT
    Text1(1).Text = ("P0")
    Text1(2).Text = ("PCON")
    Text1(3).Text = ("TCON")
    Text1(4).Text = ("TMOD")
    Text1(5).Text = ("TL0")
    Text1(6).Text = ("TL1")
    Text1(7).Text = ("TH0")
    Text1(8).Text = ("TH1")
    Text1(9).Text = ("P1")
    Text1(10).Text = ("SCON")
    Text1(11).Text = ("SBUF")
    Text1(12).Text = ("P2")
    Text1(13).Text = ("IE")
    Text1(14).Text = ("P3")
    Text1(15).Text = ("IP")
    Text1(16).Text = ("T2CON")
    m_ver.Caption = ("??")
    
    Debug.Print "be"; Me.hwnd
    Wndcla.lpszClassName = "Ch375Dbg"
    Wndcla.lpszMenuName = "Ch375dbg"
    hw = RegisterClass(Wndcla)
    Debug.Print "rc="; hw
    'hw = SetParent(Me.hwnd, Form1.hwnd)
   ' Debug.Print "spw="; hw
    'Me.Show
    'Debug.Print "pw="; GetParent(Me.hwnd)
    ' WS_CHILD +
    hw = CreateWindowEx(0, hw, _
        "Ch375Dbg" + Chr(0), WS_CAPTION + WS_OVERLAPPED + WS_TABSTOP + WS_VISIBLE, _
       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, DLGIRAM.hwnd, 0, App.hInstance, cli)
    Debug.Print "hw"; hw
End Sub

Private Sub Text2_GotFocus(Index As Integer)
Old = Trim(Text2(Index).Text)
End Sub

Private Sub Text2_LostFocus(Index As Integer)
If Index = 1 Then
    If (Old <> Trim(Text2(1).Text)) Then
        If (Not mWriteSFR(&H80, Trim(Text2(1).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
     End If
End If
If Index = 2 Then
   If (Old <> Trim(Text2(2).Text)) Then
        If (Not mWriteSFR(&H87, Trim(Text2(2).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If
If Index = 3 Then
    If (Old <> Trim(Text2(3).Text)) Then
        If (Not mWriteSFR(&H88, Trim(Text2(3).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
     End If
End If
If Index = 4 Then
    If (Old <> Trim(Text2(4).Text)) Then
        If (Not mWriteSFR(&H89, Trim(Text2(4).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
     End If
End If
If Index = 5 Then
    If (Old <> Trim(Text2(5).Text)) Then
        If (Not mWriteSFR(&H8A, Trim(Text2(5).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
     End If
End If
If Index = 6 Then
    If (Old <> Trim(Text2(6).Text)) Then
        If (Not mWriteSFR(&H8B, Trim(Text2(6).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
     End If
End If
If Index = 7 Then
    If (Old <> Trim(Text2(7).Text)) Then
        If (Not mWriteSFR(&H8C, Trim(Text2(7).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If
If Index = 8 Then
    If (Old <> Trim(Text2(8).Text)) Then
        If (Not mWriteSFR(&H8D, Trim(Text2(8).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
     End If
End If
If Index = 9 Then
    If (Old <> Trim(Text2(9).Text)) Then
        If (Not mWriteSFR(&H90, Trim(Text2(9).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If
If Index = 10 Then
    If (Old <> Trim(Text2(10).Text)) Then
        If (Not mWriteSFR(&H98, Trim(Text2(10).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
     End If
End If
If Index = 11 Then
    If (Old <> Trim(Text2(11).Text)) Then
        If (Not mWriteSFR(&H99, Trim(Text2(11).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If

If Index = 12 Then
    If (Old <> Trim(Text2(12).Text)) Then
        If (Not mWriteSFR(&HA0, Trim(Text2(12).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
         End If
    End If
End If

If Index = 13 Then
    If (Old <> Trim(Text2(13).Text)) Then
        If (Not mWriteSFR(&HA8, Trim(Text2(13).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If

If Index = 14 Then
    If (Old <> Trim(Text2(14).Text)) Then
        If (Not mWriteSFR(&HB0, Trim(Text2(14).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If

If Index = 15 Then
    If (Old <> Trim(Text2(15).Text)) Then
        If (Not mWriteSFR(&HB8, Trim(Text2(15).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If

If Index = 16 Then
    If (Old <> Trim(Text2(16).Text)) Then
        If (Not mWriteSFR(&HC8, Trim(Text2(16).Text))) Then
            MsgBox "写失败", vbOKCancel, "CH37XDBG"
        End If
    End If
End If

End Sub

⌨️ 快捷键说明

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