piclist 1999\05\27\010134a
>
Thread:
Help with C !!
www.piclist.com/techref/language/index.htm?key=c
BY
:
Javier email (remove spam text)
Hi
I have a problem, because I don´t know C- language !!!
I wan´t to know how this C code works (it sends byte trough the parallel
port to my Ti calculator, the link only has 3 wires and one is GND ).
I want to translate it to PIC, so I can interface my Ti with the PIC
Anything would help, just a few comnents and I´ll try to figure out the rest
Thanks for you time
Javier
/*
* Sends a byte to the calculator
*/
int put92(char data)
{
int bit;
for (bit=0; bit<8; bit++) {
if (bit==1) tx(1);
if (data&1) {
outportb(lpt_out, 2);
while (inportb(lpt_in)&0x10);
outportb(lpt_out, 3);
while ((inportb(lpt_in)&0x10)==0x00);
} else {
outportb(lpt_out, 1);
while (inportb(lpt_in)&0x20);
outportb(lpt_out, 3);
while ((inportb(lpt_in)&0x20)==0x00);
}
data>>=1;
// may need 10us delay here
}
}
/*
* Reads a byte from the calculator
*/
unsigned char get92(void)
{
int bit;
unsigned char data=0, v;
for (bit=0; bit<8; bit++) {
while ((v=inportb(lpt_in)&0x30) == 0x30);
if (v==0x10) {
data=(data>>1)|0x80;
outportb(lpt_out, 1);
while ((inportb(lpt_in)&0x20)==0x00);
outportb(lpt_out, 3);
} else {
data=data>>1;
outportb(lpt_out, 2);
while ((inportb(lpt_in)&0x10)==0x00);
outportb(lpt_out, 3);
}
// may need 10us delay here
}
return data;
}
<006d01bea7fd$c5c5ed80$2246a8c0@pc-de-javier>
See also: www.piclist.com/techref/language/index.htm?key=c
Reply
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the
piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
month overview.
new search...