📄 se516v36.bas
字号:
If R <> 0 Then
Set P26_io_x051_p15_data5
End If
R = C And &H40
If R <> 0 Then
Set P27_io_x051_p16_data6
End If
R = C And &H80
If R <> 0 Then
Set P17_io_x051_p17_data7
End If
Return
'----------------------------------------------------------------------------------------------------------
Preset_x051:
' INPUT :
' OUTPUT :
'
Reset P35_simulation ' Device Control Mode
Set P15_system_x051_n805x ' X051 Mode (AT89C1051, AT89C2051, AT89C4051)
Reset P16_o_x051_vcc_n ' Assert VCC (+5V)
Set P37_o_x051_vpp_n ' X051 Run Mode
Reset P36_system_clock
Set P11_o_x051_p32_prog ' X051 P3.2 / PROG High
Set P32_i_x051_p31_busy
Set P33_i_805x_p34_busy_n
C = &HFF
Gosub Write_x051
Set P10_o_x051_reset_n ' X051 Run Mode
Waitms 10
Reset P10_o_x051_reset_n ' X051 Programming Modes
Waitms 10
Return
'----------------------------------------------------------------------------------------------------------
Preset_805x:
' INPUT :
' OUTPUT :
'
Reset P35_simulation ' Device Control Mode
Reset P15_system_x051_n805x ' 805x Mode. Ocsillator Out
Reset P13_o_805x_wd_vcc
Set P34_o_805x_vpp_n ' Vpp = +5V
Reset P16_o_805x_prog_n ' ALE/PROG High
Reset P17_o_805x_psen
Set P37_o_x051_vpp_n
P0 = &HFF
Reset P10_o_805x_reset
Waitms 10
Set P10_o_805x_reset ' 805x Flash Programming Modes
Waitms 10
Return
'----------------------------------------------------------------------------------------------------------
Address_line_set:
' INPUT :
' OUTPUT :
'
P0 = Low(device_address)
Set P36_system_clock
Set P36_system_clock
Reset P36_system_clock
Reset P36_system_clock
P0 = &HFF
'
K = Device_address And &H0100 ' A8
If K <> 0 Then
Set P20_o_805x_p20_a08
Else
Reset P20_o_805x_p20_a08
End If
'
K = Device_address And &H0200 ' A9
If K <> 0 Then
Set P21_o_805x_p21_a09
Else
Reset P21_o_805x_p21_a09
End If
'
K = Device_address And &H0400 ' A10
If K <> 0 Then
Set P22_o_805x_p22_a10
Else
Reset P22_o_805x_p22_a10
End If
'
K = Device_address And &H0800 ' A11
If K <> 0 Then
Set P23_o_805x_p23_a11
Else
Reset P23_o_805x_p23_a11
End If
'
K = Device_address And &H1000 ' A12
If K <> 0 Then
Set P24_o_805x_p24_a12
Else
Reset P24_o_805x_p24_a12
End If
'
K = Device_address And &H2000 ' A13 (AT89C55WD)
If K <> 0 Then
Set P25_o_805x_p25_wd_a13
Else
Reset P25_o_805x_p25_wd_a13
End If
'
If C5x_s5xc55wd = S5x_c55wd Then ' A14 (AT89C55WD)
K = Device_address And &H4000
If K <> 0 Then
Set P33_o_805x_p34_wd_a14
Else
Reset P33_o_805x_p34_wd_a14
End If
'
Else
Set P33_i_805x_p34_busy_n
End If
'
Return
'----------------------------------------------------------------------------------------------------------
Read_device_id:
' INPUT :
' OUTPUT :
'
Manufacture_code = &H00
Device_code = &H00
Prog_voltage = &H00
Device_size = &H0000
Reset Package_type
Reset P32_o_805x_p33_mode_e ' 805X P3.3 Read Signature Byte
Reset P26_o_805x_p26_mode_d ' 805X P2.6
Reset P27_o_805x_p27_mode_c ' 805X P2.7
Reset P11_o_805x_p36_mode_b ' 805X P3.6
Reset P12_o_805x_p37_mode_a ' 805X P3.7
Gosub Preset_805x ' 805X Programming Mode
C5x_s5xc55wd = S5x_c55wd ' Device_code = At89c55wd' AT89C55WD ID Read
Device_address = &H0000
Gosub Address_line_set
Manufacture_code = P0
Device_address = &H0100
Gosub Address_line_set
Device_code = P0
If Device_code <> &H55 Then
Device_code = Device_code + &H10 ' AT89S51 = 61, AT89S52 = 62, AT89C55WD = 55
End If
Device_address = &H0200
Gosub Address_line_set
Prog_voltage = P0
If Manufacture_code <> Atmel Then ' AT89C51/AT89C52/AT89S8252 ID Read
C = &H00
Device_code = &H00
C5x_s5xc55wd = C5x_s8252
Gosub Preset_805x ' 805X Programming Mode
For I = 1 To 2
Set P27_o_805x_p27_mode_c ' 805X P2.7
Device_address = &H0030
Gosub Address_line_set
Reset P27_o_805x_p27_mode_c ' 805X P2.7
Manufacture_code = P0
Set P27_o_805x_p27_mode_c ' 805X P2.7
Device_address = &H0031
Gosub Address_line_set
Reset P27_o_805x_p27_mode_c ' 805X P2.7
Device_code = P0
Set P27_o_805x_p27_mode_c ' 805X P2.7
Device_address = &H0032
Gosub Address_line_set
Reset P27_o_805x_p27_mode_c ' 805X P2.7
Prog_voltage = P0
If Manufacture_code = Atmel Then
Exit For
End If
Reset P34_o_805x_vpp_n ' Vpp = 12V
Waitms 10
Next I
Set P34_o_805x_vpp_n ' Vpp = 5V
Waitms 10
End If
If Manufacture_code <> Atmel Then ' AT89C1051, AT89C2051, AT89C4051 ID Read
Reset P12_o_x051_p33_mode_d ' X051 P3.3
Reset P13_o_x051_p34_mode_c ' X051 P3.4
Reset P14_o_x051_p35_mode_b ' X051 P3.5
Reset P20_o_x051_p37_mode_a ' X051 P3.7
Gosub Preset_x051
Gosub Read_p1_x051
Manufacture_code = R
Set P36_system_clock
Delay
Reset P36_system_clock
Gosub Read_p1_x051
Device_code = R
End If
If Manufacture_code = Atmel Then
If Device_code = At89c51 Then
Device_size = &H1000 ' AT89C51 Flash 4K
End If
If Device_code = At89c52 Then
Device_size = &H2000 ' AT89C52 Flash 8K
End If
If Device_code = At89s8252 Then
Device_size = &H2800
End If ' AT89S8252 Flash 8K + EEPROM 2K
If Device_code = At89c55wd Then
Device_size = &H5000 ' AT89C55WD Flash 20K
End If
If Device_code = At89s51 Then
Device_size = &H1000 ' AT89S51 Flash 4K
End If
If Device_code = At89s52 Then
Device_size = &H2000 ' AT89S52 Flash 4K
End If
If Device_code = At89c1051 Then
Device_size = &H0400
Set Package_type ' AT89C1051 Flash 1K
End If
If Device_code = At89c2051 Then
Device_size = &H0800
Set Package_type ' AT89C2051 Flash 2K
End If
If Device_code = At89c4051 Then
Device_size = &H1000
Set Package_type ' AT89C4051 Flash 4K
End If
Else
Device_code = &H00
End If
If Package_type = C805x Then
Gosub Simulation_805x ' Simulation Mode
Else
Gosub Simulation_x051
End If
Return
'----------------------------------------------------------------------------------------------------------
Chip_erase_x051:
' INPUT :
' OUTPUT :
'
Gosub Preset_x051
Set P12_o_x051_p33_mode_d ' X051 P3.3 H
Reset P13_o_x051_p34_mode_c ' X051 P3.4 L
Reset P14_o_x051_p35_mode_b ' X051 P3.5 L
Reset P20_o_x051_p37_mode_a ' X051 P3.7 L
Reset P37_o_x051_vpp_n ' X051 VPP = +12V
Waitms 10
Reset P11_o_x051_p32_prog ' X051 P3.2 / PROG Low
Waitms 20
Set P11_o_x051_p32_prog ' X051 P3.2 / PROG High
Gosub Simulation_x051
Return
'----------------------------------------------------------------------------------------------------------
Chip_erase_805x:
' INPUT :
' OUTPUT :
'
Gosub Preset_805x
Set P32_o_805x_p33_mode_e ' 805X P3.3
Set P26_o_805x_p26_mode_d ' 805X P2.6
Reset P27_o_805x_p27_mode_c ' 805X P2.7
Reset P11_o_805x_p36_mode_b ' 805X P3.6
Reset P12_o_805x_p37_mode_a ' 805X P3.7
If C5x_s5xc55wd = S5x_c55wd Then ' AT89S51, AT89S52, AT89C55WD
For I = 1 To 2
Reset P34_o_805x_vpp_n ' Vpp = 12V
If Device_code = At89c55wd Then
Set P13_o_805x_wd_vcc ' VCC = 6.5V
End If
Waitms 50
Set P16_o_805x_prog_n ' 805X PROG
Set P16_o_805x_prog_n ' 805X PROG
Set P16_o_805x_prog_n ' 805X PROG
Set P16_o_805x_prog_n ' 805X PROG
Set P16_o_805x_prog_n ' 805X PROG
Reset P16_o_805x_prog_n ' 805X PROG
Waitms 500
Set P34_o_805x_vpp_n ' Vpp = 5V
Reset P13_o_805x_wd_vcc ' VCC = 5.0V
Waitms 500 '
Next I
Else
Reset P34_o_805x_vpp_n ' Vpp = 12V
Waitms 10 '
Set P16_o_805x_prog_n ' ALE/PROG Low
Waitms 20 '
Reset P16_o_805x_prog_n ' ALE/PROG High
Set P34_o_805x_vpp_n ' Vpp = 5V
End If
Gosub Simulation_805x
Return
'----------------------------------------------------------------------------------------------------------
Blank_check_x051:
' INPUT :
' OUTPUT : R &HFF -> Good
'
Gosub Preset_x051
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -