?? se516v36.bas
字號:
' *********************************************************************************************************
' * Description:
' *
' * SE516V36.BAS V3.6
' *
' * SE-516SP (ATMEL 8051 FLASH CPU SIMULATOR/PROGRAMMER)
' * Support Devices :
' *
' * AT89C1051 20 Pin 1KB FLASH
' * AT89C2051 20 Pin 2KB FLASH
' * AT89C4051 20 Pin 4KB FLASH
' * AT89C51 40 Pin 4KB FLASH
' * AT89C52 40 Pin 8KB FLASH
' * AT89S8252 40 Pin 8KB FLASH + 2KB EEPROM
' * AT89S51 40 Pin 4KB FLASH
' * AT89S52 40 Pin 8KB FLASH
' * AT89C55WD 40 Pin 20KB FLASH
' *
' * Written by Junghoon Kim 01-June-2002, 17-Oct-2003, 15-Mar-2004
' * Compiled by BASCOM 8051 V2.0.9.0
' *
' * SAMPLE Electronics co.
' * C-18 KwangJang-Fl. Main Bd. ET-Land 16-9 HanGangno-3ga
' * YongSan-gu Seoul KOREA
' * Tel: +82-2-701-8051
' * Fax: +82-2-701-8058
' * Mail : sample@korea.com
' * Web : HTTP://WWW.SAMPLE.CO.KR
' *
' *----------------------------------------------------------------------------
' * | X051 | 805X | X051 |
' *----------------------------------------------------------------------------
' * A0 HC573 Latch | | | P1.0 | 1 || 40 | VCC | | | + 5V
' * A1 " | | | P1.1 | 2 || 39 | P0.0 | | | P0.0 D0
' * A2 " | | | P1.2 | 3 || 38 | P0.1 | | | P0.1 D1
' * A3 " | | | P1.3 | 4 || 37 | P0.2 | | | P0.2 D2
' * A4 " | | | P1.4 | 5 || 36 | P0.3 | | | P0.3 D3
' * A5 " | | | P1.5 | 6 || 35 | P0.4 | | | P0.4 D4
' * A6 " | | | P1.6 | 7 || 34 | P0.5 | | | P0.5 D5
' * A7 " | | | P1.7 | 8 || 33 | P0.6 | | | P0.6 D6
' * P1.0 | | | RST | 9 || 32 | P0.7 | | | P0.7 D7
' * | | | P3.0 | 10 || 31 | VPP | | | P3.4 +5V/12V
' * !(P1.0*P3.7) | RST | 1| P3.1 | 11 || 30 | PROG |20| VCC | P1.6
' * | P3.0 | 2| P3.2 | 12 || 29 | PSEN |19| P1.7 | P1.7
' * P3.2 | P3.1 | 3| P3.3 | 13 || 28 | P2.7 |18| P1.6 | P2.7
' * P3.3 | XTAL2| 4| P3.4 | 14 || 27 | P2.6 |17| P1.5 | P2.6
' * P3.5 | XTAL1| 5| P3.5 | 15 || 26 | P2.5 |16| P1.4 | P2.5
' * P1.1 | P3.2 | 6| P3.6 | 16 || 25 | P2.4 |15| P1.3 | P2.4 A12
' * P1.2 | P3.3 | 7| P3.7 | 17 || 24 | P2.3 |14| P1.2 | P2.3 A11
' * P1.3 | P3.4 | 8| XTAL2 | 18 || 23 | P2.2 |13| P1.1 | P2.2 A10
' * P1.4, P1.5 | P3.5 | 9| XTAL1 | 19 || 22 | P2.1 |12| P1.0 | P2.1 A9
' * GND | GND |10| GND | 20 || 21 | P2.0 |11| P3.7 | P2.0 A8
' *----------------------------------------------------------------------------
' *
' * Input Command ( PC -> SE-516SP )
' *
' * I : Id Read Command
' * W : Write Data Command
' * R : Read Data Command
' * N : Blank Check Comand
' * S : Erase Command
' * A : Write Lock Bit 1
' * B : Write Lock Bit 2
' * C : Write Lock Bit 3
' * Z : Write Data End
' * T : Read Block Request
' *
' * Output Command ( SE-516SP -> PC )
' *
' * Q : Write Block Request
' *
' *********************************************************************************************************
'----------------------------------------------------------------------------------------------------------
$large ' LCALL LJMP Code
$crystal = 11059200 ' SE516SP XTAL Frequency - 11.0592MHz
$baud = 19200 ' RS232 Serial Baud Rate - 19200 BPS
'----------------------------------------------------------------------------------------------------------
Rxd_system Alias P3.0 ' Rxd
Txd_system Alias P3.1 ' Txd
P36_system_clock Alias P3.6 ' Clock Pulse : X051 - > Xtal1 / 805x - > Hc373 Latch
P15_system_x051_n805x Alias P1.5 ' Device Type : L = At89c5x(40 Pin) H = At89cx051(20 Pin)
P35_simulation Alias P3.5 ' Operating Mode : L = Device Programming H = Simulation
'----------------------------------------------------------------------------------------------------------
P10_o_805x_reset Alias P1.0 ' 805x RST
P16_o_805x_prog_n Alias P1.6 ' 805x PROG
P17_o_805x_psen Alias P1.7 ' 805x PSEN
'
P20_o_805x_p20_a08 Alias P2.0 ' 805x P2.0 Address 8
P21_o_805x_p21_a09 Alias P2.1 ' 805x P2.1 Address 9
P22_o_805x_p22_a10 Alias P2.2 ' 805x P2.2 Address 10
P23_o_805x_p23_a11 Alias P2.3 ' 805x P2.3 Address 11
P24_o_805x_p24_a12 Alias P2.4 ' 805x P2.4 Address 12
P25_o_805x_p25_wd_a13 Alias P2.5 ' 805x P2.5 Address 13 * AT89C55WD
P33_o_805x_p34_wd_a14 Alias P3.3 ' 805x P3.3 Address 14 * AT89C55WD
'
P32_o_805x_p33_mode_e Alias P3.2 ' 805x P3.3
P26_o_805x_p26_mode_d Alias P2.6 ' 805x P2.6
P27_o_805x_p27_mode_c Alias P2.7 ' 805x P2.7
P11_o_805x_p36_mode_b Alias P1.1 ' 805x P3.6
P12_o_805x_p37_mode_a Alias P1.2 ' 805x P3.7
'
P34_o_805x_vpp_n Alias P3.4 ' 805x Vpp Low = 12v(vpp) High = 5v
P13_o_805x_wd_vcc Alias P1.3 ' AT89C55WD Vcc Up(6.5v)
P14_i_805x_p30_wd_busy_n Alias P1.4 ' AT89C55WD BUSY
P33_i_805x_p34_busy_n Alias P3.3 ' 805x BUSY
'
P00_io_805x_p00_ad0 Alias P0.0 ' 805X ADDRESS & DATA 0
P01_io_805x_p01_ad1 Alias P0.1 ' 805X ADDRESS & DATA 1
P02_io_805x_p02_ad2 Alias P0.2 ' 805X ADDRESS & DATA 2
P03_io_805x_p03_ad3 Alias P0.3 ' 805X ADDRESS & DATA 3
P04_io_805x_p04_ad4 Alias P0.4 ' 805X ADDRESS & DATA 4
P05_io_805x_p05_ad5 Alias P0.5 ' 805X ADDRESS & DATA 5
P06_io_805x_p06_ad6 Alias P0.6 ' 805X ADDRESS & DATA 6
P07_io_805x_p07_ad7 Alias P0.7 ' 805X ADDRESS & DATA 7
'----------------------------------------------------------------------------------------------------------
P16_o_x051_vcc_n Alias P1.6 ' X051 VCC
P10_o_x051_reset_n Alias P1.0 ' X051 RESET
P37_o_x051_vpp_n Alias P3.7 ' X051 VPP
P11_o_x051_p32_prog Alias P1.1 ' X051 P3.2 / Prog
P32_i_x051_p31_busy Alias P3.2 ' X051 P3.1
P12_o_x051_p33_mode_d Alias P1.2 ' X051 P3.3
P13_o_x051_p34_mode_c Alias P1.3 ' X051 P3.4
P14_o_x051_p35_mode_b Alias P1.4 ' X051 P3.5
P20_o_x051_p37_mode_a Alias P2.0 ' X051 P3.7
'
P21_io_x051_p10_data0 Alias P2.1 ' X051 P1.0
P22_io_x051_p11_data1 Alias P2.2 ' X051 P1.1
P23_io_x051_p12_data2 Alias P2.3 ' X051 P1.2
P24_io_x051_p13_data3 Alias P2.4 ' X051 P1.3
P25_io_x051_p14_data4 Alias P2.5 ' X051 P1.4
P26_io_x051_p15_data5 Alias P2.6 ' X051 P1.5
P27_io_x051_p16_data6 Alias P2.7 ' X051 P1.6
P17_io_x051_p17_data7 Alias P1.7 ' X051 P1.7
'----------------------------------------------------------------------------------------------------------
Const Atmel = &H1E ' ATMEL ID Code
Const At89c1051 = &H11 ' AT89C1051 ID
Const At89c2051 = &H21 ' AT89C2051 ID
Const At89c4051 = &H41 ' AT89C4051 ID
Const At89c51 = &H51 ' AT89C51 ID
Const At89c52 = &H52 ' AT89C52 ID
Const At89s8252 = &H72 ' AT89S8252 ID
Const At89s51 = &H61 ' AT89S51 Pseudo ID = 61H : 51H OR 10H
Const At89s52 = &H62 ' AT89S52 Pseudo ID = 62H : 52H OR 10H
Const At89c55wd = &H55 ' AT89C55WD Pseudo ID = 55H
Const C805x = 0 ' ATMEL 40 Pin 8051
Const Cx051 = 1 ' AT89C1051, AT89C2051, AT89C4051
Const C5x_s8252 = 0 ' AT89C51, AT89C52, AT89S8252
Const S5x_c55wd = 1 ' AT89S51, AT89S52, AT89C55WD
'----------------------------------------------------------------------------------------------------------
Dim Flash_buffer(32) As Byte ' Buffer 32 Bytes
Dim Manufacture_code As Byte ' 0x30 : 0x1E Indicates Manufactured By Atmel
Dim Device_code As Byte ' 0x31 : 0x51(AT89C51), 0x52(AT89C52), 0x7E(AT89S8252), 0x55(AT89C55WD)
' 0x11(AT89C1051) , 0x21(AT89C2051) , 0x41(AT89C4051)
Dim Prog_voltage As Byte '
Dim Device_size As Word ' 0x0400 = AT89C1051, 0x0800 = AT89C2051, 0x1000 = AT89C4051
' 0x1000 = AT89C51, 0x2000 = AT89C52, 0x2800 = AT89S8252, 0x5000 = AT89C55WD
Dim Package_type As Bit ' 0 = 40 Pin Device , 1 = 20 Pin Device
Dim C5x_s5xc55wd As Bit ' 0 = C51, C52, S8252 / 1 = S51, S52, C55WD
Dim Device_address As Word '
'----------------------------------------------------------------------------------------------------------
Dim C As Byte , I As Byte , R As Byte , A As Byte , S As Byte
Dim J As Word , K As Word
Dim F As String * 1
'----------------------------------------------------------------------------------------------------------
' *********************************************************************************************************
Start:
Waitms 500
Gosub Read_device_id
Printhex Device_code;
Main:
S = Waitkey ' Get Command from HOST Computer
'
If S = "I" Then
Gosub Read_device_id
Printhex Device_code;
End If
'
If S = "W" Then ' Write Command
If Package_type = C805x Then
If C5x_s5xc55wd = S5x_c55wd Then
Gosub Write_code_s5x_c55wd
Else
Gosub Write_code_805x
End If
Else
Gosub Write_code_x051
End If
Print F;
End If
'
If S = "S" Then ' Erase Command
If Package_type = C805x Then
Gosub Chip_erase_805x
Else
Gosub Chip_erase_x051
End If
Print "S";
End If
'
If S = "N" Then ' Blank Check Command
If Package_type = C805x Then
Gosub Blank_check_805x
Else
Gosub Blank_check_x051
End If
If R = &HFF Then
Print "N";
Else
Print "n";
End If
End If
'
If S = "R" Then ' Read Command
If Package_type = C805x Then
Gosub Read_code_805x
Else
Gosub Read_code_x051
End If
Waitms 999
Print F;
End If
If S = "A" Then
Gosub Write_lock_bit
Print F;
End If
If S = "B" Then
Gosub Write_lock_bit
Print F;
End If
If S = "C" Then
Gosub Write_lock_bit
Print F;
End If
'
Goto Main
' *********************************************************************************************************
'----------------------------------------------------------------------------------------------------------
Simulation_x051:
' INPUT :
' OUTPUT :
'
' 76543210
P3 = &B11111111
P2 = &B11111111
P1 = &B10111110
P0 = &B11111111
Waitms 10
Set P10_o_x051_reset_n ' X051 Simulation Mode
Return
'----------------------------------------------------------------------------------------------------------
Simulation_805x:
' INPUT :
' OUTPUT :
'
' 76543210
P0 = &B11111111
P3 = &B11111111
P2 = &B11111111
P1 = &B11010110
Waitms 10
' Set P10_o_805x_reset ' 805x RST
' Waitms 5
' Reset P10_o_805x_reset ' 805x RST
Return
'----------------------------------------------------------------------------------------------------------
Read_p1_x051:
' INPUT :
' OUTPUT : R(Byte)
'
Set P21_io_x051_p10_data0 ' X051 P1.0
Set P22_io_x051_p11_data1 ' X051 P1.1
Set P23_io_x051_p12_data2 ' X051 P1.2
Set P24_io_x051_p13_data3 ' X051 P1.3
Set P25_io_x051_p14_data4 ' X051 P1.4
Set P26_io_x051_p15_data5 ' X051 P1.5
Set P27_io_x051_p16_data6 ' X051 P1.6
Set P17_io_x051_p17_data7 ' X051 P1.7
R = P2
Rotate R , Right
R = R And &H7F
If P17_io_x051_p17_data7 <> 0 Then
R = R Or &H80
End If
Return
'----------------------------------------------------------------------------------------------------------
Write_x051:
' INPUT : C
' OUTPUT :
'
Reset P21_io_x051_p10_data0
Reset P22_io_x051_p11_data1
Reset P23_io_x051_p12_data2
Reset P24_io_x051_p13_data3
Reset P25_io_x051_p14_data4
Reset P26_io_x051_p15_data5
Reset P27_io_x051_p16_data6
Reset P17_io_x051_p17_data7
R = C And &H01
If R <> 0 Then
Set P21_io_x051_p10_data0
End If
R = C And &H02
If R <> 0 Then
Set P22_io_x051_p11_data1
End If
R = C And &H04
If R <> 0 Then
Set P23_io_x051_p12_data2
End If
R = C And &H08
If R <> 0 Then
Set P24_io_x051_p13_data3
End If
R = C And &H10
If R <> 0 Then
Set P25_io_x051_p14_data4
End If
R = C And &H20
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -