R
rod_oconor
Hey,
Im doing a project which invoves using a serial A/D converter, I have
been given some C code in Pascal but i need this translated into C++
code in order to use it in the compiler that i have been told to use, I
am only new to both types of code and any help you could give me would
be greatly appreciated,
Thanks in advance,
Rod
The code is as shown here
Program serial_adc;
{Serial port AD converter circuit control program by Tomi Engdahl}
Uses Crt;
Const
combase=$2f8;
MCR=combase+4;
LCR=combase+3;
MSR=combase+6;
Procedure Initialize_converter;
Begin
Port[MCR]:=3;
Port[LCR]:=0;
End;
Function Read_value:byte;
Var
value:byte;
count:byte;
Begin
value:=0;
Port[MCR]:=1;
For count:=0 to 7 Do Begin
value:=value SHL 1;
Port[LCR]:=64;
If (port[MSR] and $10)=$10 Then Inc(value);
Port[LCR]:=0;
End;
Port[MCR]:=3;
Read_value:=value;
End;
Begin
Initialize_converter;
Repeat
Writeln(Read_value);
Until KeyPressed;
End.
Im doing a project which invoves using a serial A/D converter, I have
been given some C code in Pascal but i need this translated into C++
code in order to use it in the compiler that i have been told to use, I
am only new to both types of code and any help you could give me would
be greatly appreciated,
Thanks in advance,
Rod
The code is as shown here
Program serial_adc;
{Serial port AD converter circuit control program by Tomi Engdahl}
Uses Crt;
Const
combase=$2f8;
MCR=combase+4;
LCR=combase+3;
MSR=combase+6;
Procedure Initialize_converter;
Begin
Port[MCR]:=3;
Port[LCR]:=0;
End;
Function Read_value:byte;
Var
value:byte;
count:byte;
Begin
value:=0;
Port[MCR]:=1;
For count:=0 to 7 Do Begin
value:=value SHL 1;
Port[LCR]:=64;
If (port[MSR] and $10)=$10 Then Inc(value);
Port[LCR]:=0;
End;
Port[MCR]:=3;
Read_value:=value;
End;
Begin
Initialize_converter;
Repeat
Writeln(Read_value);
Until KeyPressed;
End.