?? se516v36.bas
字號:
Set P11_o_x051_p32_prog ' X051 P3.2 / PROG
Reset P12_o_x051_p33_mode_d ' X051 P3.3 L
Reset P13_o_x051_p34_mode_c ' X051 P3.4 L
Set P14_o_x051_p35_mode_b ' X051 P3.5 H
Set P20_o_x051_p37_mode_a ' X051 P3.7 H
For J = 1 To Device_size
Delay
Gosub Read_p1_x051
Set P36_system_clock
Delay
Reset P36_system_clock
Delay
If R <> &HFF Then
Exit For
End If
Next J
Gosub Simulation_x051
Return
'----------------------------------------------------------------------------------------------------------
Blank_check_805x:
' INPUT :
' OUTPUT : R -> &HFF
'
Gosub Preset_805x
Reset P32_o_805x_p33_mode_e ' 805X P3.3
Reset P26_o_805x_p26_mode_d ' 805X P2.6
Reset P27_o_805x_p27_mode_c ' 805X P2.7 Read
Set P11_o_805x_p36_mode_b ' 805X P3.6
Set P12_o_805x_p37_mode_a ' 805X P3.7
Device_address = 0
If Device_code = At89s8252 Then ' AT89S8252
Reset P34_o_805x_vpp_n ' Vpp = + 12V
Waitms 10
End If
While Device_address < Device_size
Set P27_o_805x_p27_mode_c ' 805X P2.7 Read
Gosub Address_line_set
Reset P27_o_805x_p27_mode_c ' 805X P2.7 Read
Delay
R = P0
Incr Device_address
If R <> &HFF Then
Exit While
End If
Wend
Set P34_o_805x_vpp_n ' Vpp = +5V
Waitms 100
Gosub Simulation_805x ' Simulation Mode
Return
'----------------------------------------------------------------------------------------------------------
Read_host:
' INPUT :
' OUTPUT :
'
Print "Q";
For I = 0 To 31 ' Buffer size
R = Waitkey
If R <> "Z" Then
If R >= "A" Then
R = R - 7
End If
Rotate R , Left
Rotate R , Left
Rotate R , Left
Rotate R , Left
R = R And &HF0
C = Waitkey
If C >= "A" Then
C = C - 7
End If
C = C And &H0F
C = C Or R
Flash_buffer(i) = C
Else
Exit For
End If
Next I
Return
'----------------------------------------------------------------------------------------------------------
Write_code_x051:
' INPUT :
' OUTPUT : F -> "W"
'
Gosub Preset_x051
Reset P12_o_x051_p33_mode_d ' X051 P3.3 L
Set P13_o_x051_p34_mode_c ' X051 P3.4 H
Set P14_o_x051_p35_mode_b ' X051 P3.5 H
Set P20_o_x051_p37_mode_a ' X051 P3.7 H
F = "W" ' W Code
Device_address = 0
While Device_address < Device_size
Gosub Read_host
If R <> "Z" Then
For I = 0 To 31 ' Buffer Size
C = Flash_buffer(i)
If C <> &HFF Then
Reset P37_o_x051_vpp_n ' X051 Vpp = + 12V
Delay
Gosub Write_x051
Waitms 1
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Bitwait P32_i_x051_p31_busy , Set
Set P37_o_x051_vpp_n ' X051 Vpp = + 5V
Waitms 1
End If
Set P36_system_clock ' X051 Xtal1 High
Delay
Reset P36_system_clock ' X051 Xtal1 Low
Delay
Incr Device_address
Next I
Else
Exit While
End If
Wend
Gosub Simulation_x051
Return
'----------------------------------------------------------------------------------------------------------
Write_code_805x:
' INPUT :
' OUTPUT : F -> "W"
'
Gosub Preset_805x
Reset P26_o_805x_p26_mode_d ' 805X P2.6
Set P27_o_805x_p27_mode_c ' 805X P2.7
Set P11_o_805x_p36_mode_b ' 805X P3.6
Set P12_o_805x_p37_mode_a ' 805X P3.7
F = "W" ' W Code
Device_address = 0
While Device_address < Device_size
Gosub Read_host
If R <> "Z" Then
For I = 0 To 31 ' Buffer Size
C = Flash_buffer(i)
If C <> &HFF Then
Gosub Address_line_set
Reset P34_o_805x_vpp_n ' Vpp = + 12V
Waitms 1
P0 = C ' Programming Byte
Set P16_o_805x_prog_n ' Prog Low
Set P16_o_805x_prog_n ' Prog Low
Set P16_o_805x_prog_n ' Prog Low
Set P16_o_805x_prog_n ' Prog Low
Reset P16_o_805x_prog_n ' Prog High
Reset P16_o_805x_prog_n ' Prog High
Reset P16_o_805x_prog_n ' Prog High
Reset P16_o_805x_prog_n ' Prog High
Bitwait P33_i_805x_p34_busy_n , Set
Set P34_o_805x_vpp_n ' Vpp = + 5V
Waitms 1
End If
Incr Device_address
Next I
Else
Exit While
End If
Wend
Gosub Simulation_805x
Return
'----------------------------------------------------------------------------------------------------------
Write_code_s5x_c55wd:
' INPUT :
' OUTPUT : F = "W"
'
Gosub Preset_805x
Set P32_o_805x_p33_mode_e ' 805X P3.3
Reset P26_o_805x_p26_mode_d ' 805X P2.6
Set P27_o_805x_p27_mode_c ' 805X P2.7
Set P11_o_805x_p36_mode_b ' 805X P3.6
Set P12_o_805x_p37_mode_a ' 805X P3.7
F = "W"
Device_address = 0
While Device_address < Device_size
'/////////////////////////////////////////////
'// Data Read from HOST Computer
'/////////////////////////////////////////////
Gosub Read_host
If R <> "Z" Then
For I = 0 To 31 ' Buffer Size
C = Flash_buffer(i)
If C <> &HFF Then
Gosub Address_line_set
Reset P34_o_805x_vpp_n ' Vpp = + 12V
P0 = C ' Programming Byte
Waitms 1
Reset P16_o_805x_prog_n ' Prog High
Set P16_o_805x_prog_n ' Prog Low
Set P16_o_805x_prog_n ' Prog Low
Reset P16_o_805x_prog_n ' Prog High
Reset P16_o_805x_prog_n ' Prog High
Reset P16_o_805x_prog_n ' Prog High
Reset P16_o_805x_prog_n ' Prog High
Bitwait P14_i_805x_p30_wd_busy_n , Set
Set P34_o_805x_vpp_n ' Vpp = +5V
Waitms 1
End If
Incr Device_address
Next I
Else
Exit While
End If
Wend
Gosub Simulation_805x ' Simulation Mode
Return
'----------------------------------------------------------------------------------------------------------
Prog_pulse_out_x051:
Reset P37_o_x051_vpp_n ' X051 Vpp = + 12V
Waitms 1
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Reset P11_o_x051_p32_prog ' X051 P3.2 / Prog Low
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Set P11_o_x051_p32_prog ' X051 P3.2 / Prog High
Bitwait P32_i_x051_p31_busy , Set
Set P37_o_x051_vpp_n ' X051 Vpp = + 5V
Waitms 1
Return
'----------------------------------------------------------------------------------------------------------
Lock_bit_x051:
' INPUT :
' OUTPUT : F
'
Gosub Preset_x051
If S = "A" Then
Set P12_o_x051_p33_mode_d ' X051 P3.3 L LB1
Set P13_o_x051_p34_mode_c ' X051 P3.4 H
Set P14_o_x051_p35_mode_b ' X051 P3.5 H
Set P20_o_x051_p37_mode_a ' X051 P3.7 H
Gosub Prog_pulse_out_x051
F = "A"
End If
If S = "B" Then
Set P12_o_x051_p33_mode_d ' X051 P3.3 L LB2
Set P13_o_x051_p34_mode_c ' X051 P3.4 H
Reset P14_o_x051_p35_mode_b ' X051 P3.5 H
Reset P20_o_x051_p37_mode_a ' X051 P3.7 H
Gosub Prog_pulse_out_x051
F = "B"
End If
Gosub Simulation_x051
Return
'----------------------------------------------------------------------------------------------------------
Prog_pulse_out_805x:
Reset P34_o_805x_vpp_n ' Vpp = + 12V
Waitms 1
Set P16_o_805x_prog_n ' Prog Low
Set P16_o_805x_prog_n ' Prog Low
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -