📄 s3c4510func.~pas
字号:
LPT D3 Pin 4 and TCK (bit 2 lptaddress )
LPT D2 Pin 5 and TDI (bit 3 lptaddress )
LPT D1 Pin 3 and TMS (bit 1 lptaddress )
LPT D0 Pin 2 and TRST (bit 0 lptaddress )
Input pin ( S3C4510 board drives)
LPT BUSY Pin 11 and TDO (bit 7 lptaddress + 1)
* modify history:
if you change the function please give the discription
----------------------------------------------------------------- }
function putp( tdi,tms,rp:integer ):integer;
var
tdo :integer;
t1, t2:integer;
begin
tdo := -1;
t1 := tdi*8 + tms*2;
OUTB( lpt_address, t1+$01 ); //TCK low
t1:= tdi*8 + tms*2 + 4;
OUTB( lpt_address, t1+$01 ); // TCK high
//need read from JTAG
if(rp = RP) then
begin
OUTB( lpt_address, tdi*8 + tms*2 + $01 ); // TCK low
t1 := INB( lpt_address + 1 );
t2 := t1 shr 7;
if(t2=1) then tdo:=0 // get TDO data
else tdo:=1;
end;
Result:=tdo;
end;
{ ----------------------------------------------------------------
* brief : hardware to reset the JTAG
* author: dailzh
* param: none
* retval: none
* modify history:
----------------------------------------------------------------- }
procedure reset_jtag;
var
i:integer;
begin
OUTB(lpt_address, 0); // TRST low
OUTB(lpt_address, 0); // TRST low
OUTB(lpt_address, 0); // TRST low
OUTB(lpt_address, 1); // TRST high
OUTB(lpt_address, 1); // TRST high
OUTB(lpt_address, 1); // TRST high
for i:=0 to 7 do
putp(1,1,IP); // move to TEST_LOGIC/RESET
putp(1,0,IP); // move to Run_Test/Idle
end;
{ ----------------------------------------------------------------
* brief : software to reset the JTAG
* author: dailzh
* param: none
* retval: none
* modify history:
----------------------------------------------------------------- }
procedure test_logic_reset;
begin
putp(1,1,IP); // keep TMS set to 1 force a test logic reset
putp(1,1,IP); // no matter where you are in the TAP controller
putp(1,1,IP);
putp(1,1,IP);
putp(1,1,IP);
putp(1,1,IP);
end;
{ ----------------------------------------------------------------
* brief : compare passed device ID to the one returned from the ID command
* author: dailzh
* param: device_id-----the checked cpu id
* retval: -1--------different
0---------the same
* modify history:
if you change the function please give the discription
----------------------------------------------------------------- }
function check_id( device_id:pchar ):integer;
var
in_id : string; //hold the get device id
DevID : string;
i : integer;
s3c_rev: integer;
a,b:byte;
begin
DevID:=device_id;
SetLength(in_id,50);
i:=35;
while(i>=1) do
begin
//add the space to the cpu id
if( i = 5 )or (i = 22 )or( i = 34 ) then
begin
in_id[i] := ' ';
i:=i-1;
end;
//read a bit from JTAG
if( putp( 1, 0, RP ) = 0 ) then
in_id[i] := '0'
else
in_id[i] := '1';
//compare to the s3c4510 cpu id
a:=ord(in_id[i]);
b:=ord(DevID[i]);
if(a<>b) and(b<>ord('*')) then
//if ( in_id[i] <> device_id[i] ) and ( device_id[i] <> '*' ) then
begin
Form1.Memo1.Lines.Add('Error,failed to read device ID');
Form1.Memo1.Lines.Add('check cables and power');
Result:=-1;
Exit;
end;
i:=i-1;
end;//for( i = 34; i >= 0; i-- )
// print S3C4510 device revision
in_id[36] := #0;
if( StrComp( PChar(in_id),S3C4510ID )=0 ) then
begin
s3c_rev :=
(ord(in_id[1]) - ord('0')) * 8 +
(ord(in_id[2]) - ord('0')) * 4 +
(ord(in_id[3]) - ord('0')) * 2 +
(ord(in_id[4]) - ord('0'));
Form1.Memo1.Lines.Add('Found S3C4510B, Revision '+inttostr(s3c_rev));
end;
Result:=0;
end;
{ ----------------------------------------------------------------
* brief : check the cpu id( JTAG part )
* author: dailzh
* param: none
* retval: -1--------error
0---------succeed
* modify history:
if you change the function please give the discription
----------------------------------------------------------------- }
function id_command:integer;
begin
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,1,IP);
putp(1,1,IP); //select IR scan
putp(1,0,IP); //capture IR
putp(1,0,IP); //shift IR
putp(0,0,IP); //S3C4510 IDCODE, LSB first
putp(1,0,IP); //
putp(1,0,IP); //
putp(1,1,IP); //Exit1-IR
putp(1,1,IP); //Update-IR
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,1,IP); //select DR scan
putp(1,0,IP); //capture DR
if( check_id( S3C4510ID )<>0 ) then
begin
Form1.Memo1.Lines.Add('failed to read device ID for the S3C4510' );
Result:= -1;
Exit;
end;
putp(1,1,IP); //Exit1-DR
putp(1,1,IP); //Update-DR
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
Result:= 0;
end;
{ ----------------------------------------------------------------
* brief : select a one bit bypass reg between TDI and TDO
* author: dailzh
* param: none
* retval: none
* modify history:
----------------------------------------------------------------- }
procedure bypass_all;
begin
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,1,IP);
putp(1,1,IP); //select IR scan
putp(1,0,IP); //capture IR
putp(1,0,IP); //shift IR
putp(1,0,IP); //S3C4510 BYPASS
putp(1,0,IP); //
putp(1,0,IP); //
putp(1,1,IP); //Exit1-IR
putp(1,1,IP); //Update-IR
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
end;
{ ----------------------------------------------------------------
* brief : select scan boundary reg between TDI and TDO
* author: dailzh
* param: none
* retval: none
* modify history:
----------------------------------------------------------------- }
procedure extest;
begin
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,1,IP);
putp(1,1,IP); //select IR scan
putp(1,0,IP); //capture IR
putp(1,0,IP); //shift IR
putp(0,0,IP); //S3C4510 extest
putp(0,0,IP); //
putp(0,0,IP); //
putp(0,1,IP); //Exit1-IR
putp(1,1,IP); //Update-IR
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
putp(1,0,IP); //Run-Test/Idle
end;
{ ----------------------------------------------------------------
* brief : read or write bus
* author: dailzh
* param: rw--------define the operation
address---the address signal of the bus
data------the write data
rp--------ignore output or not
* retval: data read from the bus
* modify history:
----------------------------------------------------------------- }
function access_bus( rw:integer; address,data:longword; rp:integer):word;
var
out_dat :array[0..300]of integer;
i :integer;
cs :integer;
li, busdat :longword;
begin
busdat:=0;
//set the chip select signal
cs := nRCS_0_OUT;
// Preset S3C4510 pins to default values (all others set in S3C4510.h)
pin[nRCS_0_OUT] := 1;
pin[nRCS_1_OUT] := 1;
pin[nRCS_2_OUT] := 1;
pin[nRCS_3_OUT] := 1;
pin[nRCS_4_OUT] := 1;
pin[nRCS_5_OUT] := 1;
pin[nECS_0_OUT] := 1;
pin[nECS_1_OUT] := 1;
pin[nECS_2_OUT] := 1;
pin[nECS_3_OUT] := 1;
pin[nOE_OUT] := 0;
pin[nWBE_0_OUT] := 1;
pin[nWBE_1_OUT] := 1;
pin[nWBE_2_OUT] := 1;
pin[nWBE_3_OUT] := 1;
pin[D_OUT_ENB] := 0;
for i := 0 to 21 do
pin[149-i] := integer((address shr i) and 1); // set address 0 thru 21
if(rw = READ) then
begin
pin[cs] := 0;
pin[D_OUT_ENB] := 1;
pin[nOE_OUT] := 0;
end;
if(rw = WRITE) then
begin
pin[cs] := 0;
pin[nWBE_0_OUT] := 0;
pin[nOE_OUT] := 1;
pin[D_OUT_ENB] := 0; // switch data pins to drive
for li := 0 to 31 do
pin[125-li*2] := integer((data shr li) and 1); // set data pins
end;
if( rw = HOLD) then // just like a write except WE, WE needs setup time
begin
pin[cs] := 1;
pin[nOE_OUT] := 1;
pin[D_OUT_ENB] := 0;
pin[nWBE_0_OUT] := 1;
//for(li = 0L; li < 32L; li++)
// pin[125-li*2] = (int)((data >> li) & 1L); // serialize data pins
end;
if(rw = SETUP ) then// just like a write except WE, WE needs setup time
begin
pin[cs] := 0;
pin[nOE_OUT] := 1;
pin[D_OUT_ENB] := 0;
pin[nWBE_0_OUT] := 1;
for li := 0 to 31 do
pin[125-li*2] := integer((data shr li) and 1); // serialize data pins
end;
if(rw = RS) then // setup prior to RD_nWR_OUT
begin
pin[nOE_OUT] := 1;
pin[cs] := 0;
pin[nWBE_0_OUT] := 0;
end;
putp(1,0,IP); // Run-Test/Idle
putp(1,0,IP); // Run-Test/Idle
putp(1,0,IP); // Run-Test/Idle
putp(1,0,IP); // Run-Test/Idle
putp(1,1,IP); // select DR scan
putp(1,0,IP); // capture DR
putp(1,0,IP); // shift IR
for i := 0 to 231 do // shift write data in to JTAG port and read data out
out_dat[i] := putp(pin[i],0,rp);
putp(0,1,IP); // Exit1-DR
putp(1,1,IP); // Update-DR
putp(1,0,IP); // Run-Test/Idle
putp(1,0,IP); // Run-Test/Idle
putp(1,0,IP); // Run-Test/Idle
busdat := 0;
for i := 0 to 31 do // convert serial data to single DWORD
busdat := busdat or word(out_dat[125 - i*2] shl i);
Result:=busdat;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -