Area : ‘奬ë Date : Mon Jun 09, 00:17 From : Dima Orlov 2:461/27 To : Alex Kulyasov Subj : EEPROM ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Hello, Alex Kulyasov ! >>> ¯à®£à ¬¬ â®àë ¤«ï EEPROM®¢ ⨯  24á01/02... …᫨ ªâ® ¢¨¤¥« ¨«¨ á«ëè « > DO> Ÿ ¦¥ á ­¥¤¥«î ­ § ¤ ª¨¤ « á ¤«ï 24á16. Hã çã⮪ ¯à®£à ¬¬ªã ¤«ï íâ¨å > DO> ¯®¤¯à ¢¨âì ¨ ¢á¥. ‚á¥å ¤¥«®¢ - ®¤¨­ âà ­§¨áâ®à, ¯ à  १¨áâ®à®¢ ¨ lpt > DO> ¯®àâ. > Hã ­¥ ¤®å®¤¨« ... •®à®è®, ¢ ç¥â¢¥àâë© (¨«¨ ¯ïâë©?) à §, «®¢¨: uses CRT; var LPT1: Word; A: Word; Mode: (mError, mRead, mWrite); FileName: String[80]; Buf : Array[0..2047] of byte; F: File; { 24C16 LPT 1ÚÄÄÄÂÄÄÄÂÄÄÄ¿8 ÚÄÄÄÄÄ´A0 ³ E ³VccÃÄÄÄÄÄÂÄÄÄÄ>D1 (Pin 3) ³ 2³ ³ E ³ ³7 ÚÁ¿ ³ÚÄÄÄÄ´A1 ³ P ³ WPÃÄ 0 ³\³15k ³³ 3³ ³ R ³ ³6 ³\³ ³³ÚÄÄÄ´A2 ³ O ³SCLÃÄÄÄ¿ÀÂÙ ÚÄ>D2 (Pin 4) ³³³ 4³ ³ M ³ ³5 ÀÄÅÄÄÙ ³³³ ÚÄ´GND³ ³SDAÃÄÄÂÄÄÁÄÄÄÄ>ACK (Pin 10) ³³³ ³ ÀÄÄÄÁÄÄÄÁÄÄÄÙ ³ ³³³ ³ ³/ ª ³³³ ³ ÚÄ´ ³³³ ³ ÚÁ¿³\ í ³³³ ³ ³\³ ³ ³³³ ³ 1k³\³ ³ ÚÄ>D0 (Pin 2) ³³³ ³ ÀÂÙ ³ ³ ³³³ ³ ÀÄÄÄÅÄÄÄÄÄÙ ³³³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄ>GND (Pin 25) ³³³ ³³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>D3 (Pin 5) ³³ ³ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>D4 (Pin 6) ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ>D5 (Pin 7) } procedure Pause; assembler; asm push ax @@0: jmp @@1 @@1: in al, dx pop ax end; procedure Start; assembler; asm mov dx, lpt1 mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause mov al, 00000111b {Vcc = 1, SCL = 1, SDA = 0} out dx, al call Pause mov al, 00000011b {Vcc = 1, SCL = 0, SDA = 0} out dx, al call Pause end; procedure Stop; assembler; asm mov dx, lpt1 mov al, 00000111b {Vcc = 1, SCL = 1, SDA = 0} out dx, al call Pause mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause end; function PutByte(B: Byte): boolean; assembler; asm mov dx, lpt1 mov ah, B mov cx, 8 @@0: rcl ah,1 jc @@1 mov al, 00000011b {Vcc = 1, SCL = 0, SDA = 0} out dx, al call Pause mov al, 00000111b {Vcc = 1, SCL = 1, SDA = 0} out dx, al call Pause mov al, 00000011b {Vcc = 1, SCL = 0, SDA = 0} out dx, al jmp @@2 @@1: mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al call Pause mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al @@2: loop @@0 call Pause mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause inc dx in al, dx dec dx and al, 01000000b mov ah, 1 je @@3 mov ah, 0 @@3: mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al mov al, ah end; function GetByte: byte; assembler; asm mov dx, lpt1 mov cx, 8 @@0: mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause inc dx in al, dx dec dx and al, 01000000b shl al,1 shl al,1 rcl ah, 1 mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al call Pause loop @@0 mov al, 00000110b {Vcc = 1, SCL = 1, SDA = 1} out dx, al call Pause mov al, 00000010b {Vcc = 1, SCL = 0, SDA = 1} out dx, al call Pause mov al, ah end; procedure WriteByte(Addr:Word; B : Byte); begin Start; PutByte($A0 or ((Hi(Addr) shl 1) and $0e)); PutByte(Lo(Addr)); PutByte(B); Stop; Delay(5); end; function ReadByte(Addr:Word): Byte; begin Start; PutByte($A0 or ((Hi(Addr) shl 1) and $0e)); PutByte(Lo(Addr)); Start; PutByte($A1 or ((Hi(Addr) shl 1) and $0e)); ReadByte := GetByte; Stop; end; procedure ComStr; var PCStr : ^String; i: Byte; begin PCStr := Ptr(PrefixSeg, $80); for i := 0 to length(PCStr^) -1 do if PCStr^[i] in ['-', '/'] then begin case PCStr^[i+1] of 'r', 'R' : Mode := mRead; 'w', 'W' : Mode := mWrite; else Mode := mError; end; Delete(PCStr^, i, 2); Break; end; if ParamCount = 0 then Mode := mError else FileName := ParamStr(1); end; begin LPT1 := $378; asm mov dx, lpt1 mov al, 00000110b out dx, al end; ComStr; Assign(F, FileName); case Mode of mRead: begin for A:= 0 to 2047 do Buf[A] := ReadByte(A); Rewrite(F, 1); if IOResult = 0 then begin BlockWrite(F, Buf, SizeOf(Buf)); Close(F); end; end; mWrite: begin Reset(F, 1); if IOResult = 0 then begin BlockRead(F, Buf, SizeOf(Buf)); Close(F); for A:= 0 to 2047 do WriteByte(A, Buf[A]); end; end; mError: begin WriteLn('24c16 fileName -r|-w'); WriteLn(' -r Read'); WriteLn(' -w Write'); end; end; end. ‘ 㢠¦¥­¨¥¬, „¨¬  Žà«®¢ --- [CONNECT Team] * Origin: Electric BBS (0572) 477-177 (2:461/27)