Kulwinder Atwal wrote:
>
> So then:
> 
>  void count(int time)
>    {
>      int value = 0;
>      while (value < time) {
>         while (inb(BASEPORT+1) & 0x80);
>         while (inb(BASEPORT+1) ^ 0x80);
>         value++;
> 
>      }
>    }

I haven't tried it out yet, but I don't think this function will work...

This is the situation:

I have a 109 kHz signal on pin 11 of my parallel port.  I want to count
10000 pulses.

so... first i do

while (inb(BASEPORT+1) & 0x80);

to check if it's high.  This means if the parallel port was 1XXXXXX then
with this AND function i get:

1XXXXXXX
10000000
-------- (AND)
10000000

Which is a decimal value of 2^7=128, which is not zero, so I will stay
in this loop until i get 0XXXXXXX.

Then, after the bit on pin 11 went low, i have to stay in a while loop
until it gets back high... if i do that lik you say, with XOR, then i
get:

0XXXXXXX
10000000
-------- (XOR)
1XXXXXXX

which is ok for the moment, but let's say that the bin on pin 11 gets
low and i get 0XXXXXX then normally i should leave the while loop, but
it is not sure if that will happen, because one of the X's could be
non-zero and that means i will stay in the while loop.  So i guess it's
better to say

do
  {
   klok = inb(BASEPORT+1) & 0x80;
  }
while (klok == 0);

because this will give me:

0XXXXXXX
10000000
-------- (AND)
00000000

And here I'm sure that i have a value of zero!

If someone else has a better idea of a routine to count the amount of
pulses that arrives on pin 11 of the parallel port, then please let me
know!  The algorithm I'm using right now is:

void count(int time)
{
  int value = 0;
  int clock;

  while (value < time) {
    do
      {
       clock = inb(BASEPORT+1) & 0x80;
      }
    while (clock == 0);

    do
      {
       clock = inb(BASEPORT+1) & 0x80;
      }
    while (clock == 0x80);

    value++;
  }
}

Greetzzz
MC303

-- 
Bart Vandewoestyne              http://hello.to/MC303           
Hugo Verrieststraat 48          [EMAIL PROTECTED]
8550 ZWEVEGEM                   ICQ# 21275340
BELGIUM - EUROPE                nick: MC303
Phone: +32(0)56/75.48.11
-------------------------------------------------------------
"Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das
nennen sie ihren Standpunkt."

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to