



procedure TForm1.ReadTLC1543Values;
var
i, j, temp: integer;
addr: string[4];
val: integer;
EOC: boolean;
timeOut: integer;
t: longInt;
begin
timeOut := 20;
for i := 0 to 13 do
begin
// adresse de l'entrée à lire
addr := byteToBits(i, 4);
// récupération des valeurs échantillonnées par le TLC1543
temp := 1024;
val := 0;
for j := 1 to 10 do
begin
temp := temp div 2;
if j < 5 then
WriteAddr(copy(Addr, j, 1) = '1') // via RTS
else
WriteAddr(false); // via RTS
WriteCLK(true); // front montant de l'horloge // via DTR
if ReadDataBit then
val := val + temp; // via CTS
WriteCLK(false); // front descendant de l'horloge // via DTR
end;
// wait for End Of Conversion
t := GetTickCount;
repeat
EOC := ReadEOC; // via DSR
until EOC or (GetTickCount > (t + timeOut));
// stockage dans le tableau des valeurs
case i of
0 : TLC1543Values[13] := val;
1..13 : TLC1543Values[i - 1] := val;
end;
end;
end;