Einzelnen Beitrag anzeigen

Muetze1
(Gast)

n/a Beiträge
 
#2

Re: 16-Bit Folge über LPT ausgeben

  Alt 14. Jan 2008, 13:40
Delphi-Quellcode:
procedure WriteWord(const APort: Word; const AData: Word);
const
  CLOCK = 1;
  LOAD = 2;
  DATA = 4;
var
  i: integer;
  lData: Word;
  lPortData: Byte;
  lBit: boolean;
begin
  lData := AData;

  // Wenn LOAD definitv auf high ist beim reinspringen in diese Proc, dann können die ersten beiden Zeilen weg...
  //PortIO(APort, LOAD);
  //Delay(20);
  PortIO(APort, 0);

  for i := 0 to 15 do
  begin
      // Bit ermitteln
    lBit := ( lData and $8000 ) <> 0; // falls es dann gespiegelt ist, dann halt lBit := ( lData and 1 ) <> 0 und unten shr statt shl
    lData := lData shl 1;
    
    lPortData := CLOCK;
    if lBit then
      lPortData := lPortData or DATA;
    
    PortIO(APort, lPortData);
    Delay(20);
    PortIO(APort, lPortData and not CLOCK);
    Delay(20);
  end;

  PortIO(APort, LOAD);
end;
Ungetestet und hier im Beitragseditor getippelt...
  Mit Zitat antworten Zitat