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

📄 se516v36.frm

📁 C51单片机的程序下载器软件源代码
💻 FRM
📖 第 1 页 / 共 3 页
字号:

COMDIA.ShowOpen                             ' 傍侩 措拳惑磊(颇老 急琶)甫 坷锹.

If Err.Number = cdlCancel Then Exit Sub     ' "秒家"甫 努腐窍搁 辑宏风凭阑 辆丰.

If COMDIA.FileName <> "" Then

   F = FreeFile()
   
   Open COMDIA.FileName For Output As F
   
   Form1.Caption = COMDIA.FileName

For I = 0 To g

       C = 0
       t = "0000" + Hex(I * 16)
       v = ":10" + Right(t, 4) + "00"

       For J = 0 To 15
         v = v + MSFG.TextMatrix(I + 1, J + 1)
       Next J
       
       C = 0
       For K = 2 To 40 Step 2
         C = C + Val("&H" + Mid(v, K, 2))
       Next K
         C = Not C
         C = C And &HFF
         C = C + 1
         t = "0" + Hex(C)
         t = Right(t, 2)
         v = v + t
                  
         Print #F, v
Next I

t = ":00000001FF" + Chr(13) + Chr(10)
Print #F, t
       
Close F

End If

Beep

End Sub

Private Sub Blank_Click()
' Blank Check

Reset_Click

MSComm1.PortOpen = True
MSComm1.Output = "N"          ' blaNk

serialinput (1)
MSComm1.PortOpen = False

If train = "N" Then

  msgtxt = "Blank OK !"
  msgout

  ElseIf train = "n" Then

  msgtxt = "Blank Error !"
  msgout
  
  MsgBox "Blank Check ERROR", vbExclamation, "BLANK CHECK"
 
  Else
 
 MsgBox "System ERROR", vbCritical, ""
 
End If

Beep

End Sub

Private Sub Program_Click()
' Programm

Dim I As Integer
Dim J As Integer
Dim b As Integer
Dim m As Long

Reset_Click

If flashsize = 0 Then MsgBox "System ERROR", vbCritical, "PROGRAM": Exit Sub

MSComm1.PortOpen = True

b = 0

m = proghexsize

MSComm1.Output = "W"

While m <> 0

serialinput (1)
If train <> "Q" Then GoTo label_prog_a

For I = 0 To 1
  For J = 0 To 15
    MSComm1.Output = MSFG.TextMatrix(b + I + 1, J + 1)
  Next J

Next I
  b = b + 2
m = m - 32

Wend

If flashsize <> proghexsize Then

serialinput (1)      ' Q
MSComm1.Output = "Z"

End If

serialinput (1)      ' W

label_prog_a:

If train = "W" Then

  msgtxt = "Write OK !"
  msgout

  ElseIf train = "w" Then

  msgtxt = "Write Error !"
  msgout
  
  MsgBox "Write ERROR", vbExclamation, ""
 
  Else
 
 MsgBox "System ERROR", vbCritical, "PROGRAM"
 
End If
 
MSComm1.PortOpen = False

Beep

End Sub

Private Sub Read_Click()
' Read Command

Dim b As Integer
Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim m As Long

Reset_Click

MSComm1.PortOpen = True

b = 0

m = flashsize
proghexsize = flashsize

MSComm1.Output = "R"

While m <> 0

MSComm1.Output = "T"

serialinput (64)

K = 1

For I = 0 To 1
  For J = 0 To 15
  
  MSFG.TextMatrix(b + I + 1, J + 1) = Mid(train, K, 2)
  K = K + 2
  Next J

Next I
b = b + 2
m = m - 32

Wend

serialinput (1)

If train = "R" Then

  msgtxt = "Read OK !"
  msgout
  
  progmark = True
  
  ElseIf train = "r" Then

  msgtxt = "Read Error !"
  msgout
  
  MsgBox "Read ERROR", vbExclamation, ""
 
  Else
 
 MsgBox "System ERROR", vbCritical, "PROGRAM"
 
End If
 
MSComm1.PortOpen = False

Beep

End Sub

Private Sub Verify_Click()
' Verify Command

Dim b As Integer
Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim m As Long
Dim S As Integer

Reset_Click

S = 0

MSComm1.PortOpen = True

b = 0
m = flashsize

MSComm1.Output = "R"

While m <> 0

MSComm1.Output = "T"

serialinput (64)

K = 1

For I = 0 To 1
  For J = 0 To 15
    If (MSFG.TextMatrix(b + I + 1, J + 1) <> Mid(train, K, 2)) Then S = 1
    K = K + 2
  Next J

Next I

b = b + 2
m = m - 32

Wend

serialinput (1)

If train = "R" Then

  If S = 0 Then
  
    msgtxt = "Verify OK !"
    msgout
    
  Else
  
    msgtxt = "Verify Error !"
    msgout
    
    MsgBox "Vefify ERROR", vbExclamation, ""
    
  End If

 Else
 
 MsgBox "System ERROR", vbCritical, "PROGRAM"
 
 End If

MSComm1.PortOpen = False

Beep

End Sub

Private Sub Reset_Click()
' 矫府倔器飘 坷锹饶 Device Id 犬牢

Dim t As String

MSComm1.PortOpen = True

t = MSComm1.Input    ' Buffer Clear

 flashsize = 0
 
 AT89C1051.Value = False
 AT89C2051.Value = False
 AT89C4051.Value = False
 AT89C8051.Value = False
 AT89C8052.Value = False
 AT89S8252.Value = False
 AT89C55WD.Value = False

MSComm1.Output = "I" ' First ID Read

serialinput (2)      ' 矫府倔 器飘肺 2 俺 官捞飘甫 佬绢柯促

If train = "11" Then AT89C1051.Value = True: flashsize = &H400: GoTo labela
If train = "21" Then AT89C2051.Value = True: flashsize = &H800: GoTo labela
If train = "41" Then AT89C4051.Value = True: flashsize = &H1000: GoTo labela
If train = "51" Then AT89C8051.Value = True: flashsize = &H1000: GoTo labela
If train = "52" Then AT89C8052.Value = True: flashsize = &H2000: GoTo labela
If train = "72" Then AT89S8252.Value = True: flashsize = &H2800: GoTo labela
If train = "61" Then AT89S51.Value = True: flashsize = &H1000: GoTo labela
If train = "62" Then AT89S52.Value = True: flashsize = &H2000: GoTo labela
If train = "55" Then AT89C55WD.Value = True: flashsize = &H5000: GoTo labela

labela:

MSComm1.PortOpen = False

End Sub

Private Sub Load_Click()
' Load Command

Dim InputData As String
Dim t As String      ' Temporary String
Dim F As Integer     ' FILE Number
Dim A As Long        ' Address
Dim I As Long
Dim J As Long
Dim R As Integer     ' Record Type
Dim S As Integer     ' Data Size
Dim d As Byte        ' Data Byte
   
readhexsize = 0

MSFG.Visible = False

If comdiaskip <> True Then

COMDIA.ShowOpen                   ' 傍侩 措拳惑磊(颇老 急琶)甫 坷锹.

If Err.Number = cdlCancel Then
   
   loadsucess = False
   Exit Sub     ' "秒家"甫 努腐窍搁 辑宏风凭阑 辆丰.
   
Else
   
   loadsucess = True
   
End If

loadfilename = COMDIA.FileName

Else


End If


If loadfilename <> "" Then

   F = FreeFile()
   
   Open loadfilename For Input As F
    
   If Fillchk.Value = 1 Then          '选择 【填充FF】
      buffer_initial
   End If
     
    Do While Not EOF(1)           ' 颇老狼 场牢瘤 犬牢钦聪促.
      
      Line Input #F, InputData    ' 单捞磐 青阑 佬绢 甸涝聪促. 【: 02 0000 00 01 30 CD】
      t = Mid(InputData, 2, 2)    ' 单捞磐 康开 辨捞 馆券钦聪促.
      S = Val("&H" + t)
      t = Mid(InputData, 4, 4)
      A = Val("&H0" + t)
      
      If A < 0 Then A = A + 65536
            
      I = 10                      ' 单捞磐 备埃 霉锅掳 困摹
      While S <> 0
      
        t = Mid(InputData, I, 2)
        d = Val("&H" + t)
        buffer(A) = d             ' 滚欺俊 单捞磐 历厘
        I = I + 2                 ' 胶飘傅 困摹 2 官捞飘 刘啊
        A = A + 1                 ' 绢靛饭胶 1 刘啊
        S = S - 1                 ' 单捞磐 荤捞令 1 皑家
        
        If A > readhexsize Then
          readhexsize = A
        End If
      
      Wend
      
    Loop
   
   Close F
   
   proghexsize = readhexsize - 1
   proghexsize = (proghexsize Or &H1F) + 1
   
'   Form1.Caption = loadfilename + " - " + Str(readhexsize) + " Bytes (" + Hex(readhexsize) + "H)" + Hex(proghexsize)
   Form1.Caption = loadfilename + " - " + Str(readhexsize) + " Bytes (" + Hex(proghexsize) + "H)"
   
   progmark = True
   
   For I = 0 To 4095
   
     t = "0000" + Hex(I * 16)
     MSFG.TextMatrix(I + 1, 0) = Right(t, 4)
  
     For J = 0 To 15
       t = "0" + Hex(buffer(16 * I + J))
       MSFG.TextMatrix(I + 1, J + 1) = Right(t, 2)
     Next J
   
   Next I

End If
MSFG.Visible = True

Beep

End Sub

Private Sub Form_Load()

progmark = False

msgtxt = "ATMEL 8051 Programmer": msgout
msgtxt = "SAMPLE Electronics co.": msgout
msgtxt = "TEL: (02)701-8051": msgout
msgtxt = "WEB: www.SAMPLE.co.kr": msgout

buffer_initial

Erase_chk.Value = 1
Program_chk.Value = 1
autochk.Value = 1

comdiaskip = False
loadsucess = False

End Sub

⌨️ 快捷键说明

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