?? bear.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Bear
BackColor = &H8000000B&
BorderStyle = 1 'Fixed Single
Caption = "AT89Cx051編程器V1.0"
ClientHeight = 2415
ClientLeft = 5910
ClientTop = 4050
ClientWidth = 4215
Icon = "Bear.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2415
ScaleWidth = 4215
Begin VB.Timer AutoTimer
Enabled = 0 'False
Interval = 500
Left = 2040
Top = 2040
End
Begin VB.CommandButton WriteLockBits
Caption = "加 密"
Height = 375
Left = 2280
TabIndex = 15
Top = 1560
Width = 735
End
Begin VB.CommandButton Read
Caption = "校 驗"
Height = 375
Index = 1
Left = 2280
TabIndex = 14
Top = 1080
Width = 735
End
Begin VB.CommandButton Write
BackColor = &H8000000B&
Caption = "寫 入"
Height = 375
Left = 2280
MaskColor = &H80000000&
TabIndex = 13
Top = 600
Width = 735
End
Begin VB.CommandButton Eraze
Caption = "擦 除"
Height = 375
Left = 2280
Picture = "Bear.frx":0CCA
TabIndex = 12
Top = 120
Width = 735
End
Begin VB.Frame AutoCheck
Caption = "組合操作"
Height = 1815
Left = 3120
TabIndex = 6
Top = 120
Width = 975
Begin VB.CommandButton Auto
Caption = "執 行"
Height = 375
Left = 120
TabIndex = 11
Top = 1320
Width = 735
End
Begin VB.CheckBox AutoLock
Caption = "加密"
Height = 255
Left = 120
TabIndex = 10
Top = 960
Width = 735
End
Begin VB.CheckBox AutoVerify
Caption = "校驗"
Height = 255
Left = 120
TabIndex = 9
Top = 720
Value = 1 'Checked
Width = 735
End
Begin VB.CheckBox AutoWrite
Caption = "寫入"
Height = 255
Left = 120
TabIndex = 8
Top = 480
Value = 1 'Checked
Width = 735
End
Begin VB.CheckBox AutoEraze
Caption = "擦除"
Height = 255
Left = 120
TabIndex = 7
Top = 240
Value = 1 'Checked
Width = 735
End
End
Begin VB.CommandButton Read
Caption = "讀出代碼"
Height = 495
Index = 0
Left = 1200
TabIndex = 5
Top = 1200
Width = 975
End
Begin VB.CommandButton Identify
Caption = "識別芯片"
Height = 495
Left = 1200
TabIndex = 4
Top = 600
Width = 975
End
Begin VB.Timer ReadTimer
Enabled = 0 'False
Interval = 1
Left = 1560
Top = 2040
End
Begin VB.Timer ErazeTimer
Enabled = 0 'False
Interval = 10
Left = 1080
Top = 2040
End
Begin VB.Timer WriteTimer
Enabled = 0 'False
Interval = 1
Left = 600
Top = 2040
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 120
Top = 2040
End
Begin MSComDlg.CommonDialog Cmd1
Left = 2760
Top = 2040
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MSCommLib.MSComm Com1
Left = 3360
Top = 2040
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
InBufferSize = 1
BaudRate = 38400
End
Begin MSComctlLib.ProgressBar Progress
Height = 255
Left = 120
TabIndex = 2
Top = 2040
Width = 3975
_ExtentX = 7011
_ExtentY = 450
_Version = 393216
Appearance = 1
End
Begin VB.CommandButton LoadFile
Caption = "載入文件"
Height = 495
Left = 120
TabIndex = 1
Top = 1200
Width = 975
End
Begin VB.ComboBox Type1
Height = 300
Left = 120
TabIndex = 0
Text = "請設定芯片型號"
Top = 120
Width = 2055
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "COM1"
Height = 255
Left = 120
TabIndex = 17
Top = 840
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "通訊端口:"
Height = 255
Left = 120
TabIndex = 16
Top = 600
Width = 975
End
Begin VB.Label Status
Alignment = 2 'Center
Caption = "AT89Cx051 編程器 V1.0"
Height = 255
Left = 120
TabIndex = 3
Top = 1800
Width = 2055
End
End
Attribute VB_Name = "Bear"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Busy As Boolean '系統繁忙
Dim Opration As String '操作模式
Dim Codes As String '文件代碼緩沖
Dim SignatureCode(0 To 1) As Byte '簽名字節
Dim SigAddr As Integer
Dim AddrH, AddrL As Integer '地址高位和低位
Dim Address(0 To 4095) As Integer '地址
Dim Code(0 To 4095) As Byte '代碼
Dim Sendbuffer(1 To 1) As Byte '數據發送緩沖器
Dim TypeProcedue As Integer '設定芯片型號時的步驟
Dim WriteProcedue As Integer '寫入時協議步驟
Dim Code_Num As Integer '當前行代碼數量
Dim Code_all, Code_Max As Long '當前文件代碼總數,讀入時最大代碼數量
Dim i, Addr As Integer
Dim Verify_Code As Integer '檢驗位計算變量
Dim Command As String '命令
Dim Disconnect As Integer '連接超時計數器
Private Sub Auto_Click()
If Busy = True Then Exit Sub
AutoTimer.Enabled = True
Opration = "NonOpration"
End Sub
Private Sub AutoTimer_Timer()
If Busy = True Then Exit Sub
If Opration = "NonOpration" Then
If AutoEraze.Value = 1 Then
Eraze_Click
End If
Opration = "Eraze"
ElseIf Opration = "Eraze" Then
If AutoWrite.Value = 1 Then
Write_Click
End If
Opration = "Write"
ElseIf Opration = "Write" Then
If AutoVerify.Value = 1 Then
Read_Click (1)
End If
Opration = "Verify"
ElseIf Opration = "Verify" Then
If AutoLock.Value = 1 Then
WriteLockBits_Click
End If
Opration = "WriteLockBits"
ElseIf Opration = "WriteLockBits" Or Opration = "Failed" Then
AutoTimer.Enabled = False
End If
End Sub
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'初始化時自動連接設備,識別芯片型號,已經確定
Private Sub Form_Load()
'On Error GoTo NextPort
Type1.AddItem "AT89C1051"
Type1.AddItem "AT89C1051U"
Type1.AddItem "AT89C2051"
Type1.AddItem "AT89C2051x2"
Type1.AddItem "AT89C4051" '初始化芯片選擇框
For i = 0 To 4095
Code(i) = 255 '所有內容預置為 FF
Next i
Code_all = 0
' For i = 1 To 100
' Com1.CommPort = i
' Com1.PortOpen = True
' 'Exit Sub
' Com1.PortOpen = False
'NextPort:
' Next i
Com1.PortOpen = True
Busy = True
Opration = "Connect"
Timer1.Enabled = True '開始檢測連接
End Sub
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
''手動連接設備,識別芯片型號,已經確定
Private Sub Identify_Click()
If Busy = True Then Exit Sub
Busy = True
If Com1.PortOpen = False Then
Com1.PortOpen = True
End If
Status.Caption = "正在連接,請稍候!"
Opration = "Connect"
Progress.Value = 0
Timer1.Enabled = True
End Sub
'手動設定芯片型號,已經確定
Private Sub Type1_Click()
Select Case Type1.Text
Case "AT89C1051": SignatureCode(1) = 17
Case "AT89C1051U": SignatureCode(1) = 18
Case "AT89C2051": SignatureCode(1) = 33
Case "AT89C2051x2": SignatureCode(1) = 34
Case "AT89C4051": SignatureCode(1) = 65
End Select
If SignatureCode(1) > 0 Then
Com1.Output = Trim("T")
Opration = "SetMcuType"
TypeProcedue = 0
Disconnect = 0
Progress.Value = 0
Timer1.Enabled = True
End If
End Sub
Private Sub SetType()
If SignatureCode(1) = 17 Then
Status.Caption = "AT89C1051"
Type1.Text = "AT89C1051"
Code_Max = 1024
ElseIf SignatureCode(1) = 18 Then
Status.Caption = "AT89C1051U"
Type1.Text = "AT89C1051U"
Code_Max = 1024
ElseIf SignatureCode(1) = 33 Then
Status.Caption = "AT89C2051"
Type1.Text = "AT89C2051"
Code_Max = 2048
ElseIf SignatureCode(1) = 34 Then
Status.Caption = "AT89C2051x2"
Type1.Text = "AT89C2051x2"
Code_Max = 2048
ElseIf SignatureCode(1) = 65 Then
Status.Caption = "AT89C4051"
Type1.Text = "AT89C4051"
Code_Max = 4096
Else
Status.Caption = "無法識別,請直接設定"
End If
End Sub
Private Sub Timer1_Timer()
If Com1.InBufferCount > 0 Then
Command = Com1.Input
Progress.Value = 0
Disconnect = 0
If Opration = "Connect" Then '檢測設備連接
If Command = "C" Then '回應正確
Status.Caption = "設備已連接!歡迎使用!"
Opration = "Signature"
Com1.InputMode = comInputModeBinary
Com1.Output = Trim("S") '發送讀標志代碼命令
SigAddr = 0
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -