Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Interrupt routine of a parallel port on Pascal


  • Please log in to reply

#1
lucas89_chuck

lucas89_chuck

    New Member

  • Member
  • Pip
  • 4 posts
Hi, I would like some help here!

I need to know how to do an interrupt routine of a parallel port on Pascal for my university's scientifc research!

I appreciate the attention!

  • 0

Advertisements


#2
PaulOF

PaulOF

    Member

  • Member
  • PipPip
  • 20 posts
Hi,
I may or may not be able to help, but first I need a little more information.
What platform? What operating system? What kind of Pascal? What kind of parallel port? If it's a PC printer port is it SPP, ECP, EPP? What kind of latency can you tolerate?

I am guessing that you are trying to do some sort of real time data collection. Do you have any flexibility with respect to the kind of hardware and operating system you use?

I apologize if it sounds as if I am trying to answer more than you asked. It's just that the more I know about your problem, the more likely it is that I can offer some useful advice. :)

Paul
  • 0

#3
lucas89_chuck

lucas89_chuck

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts
Thanks, PaulOF!

Well, now I'm using Windows 98, because this windows allow me to reboot in DOS. I preffer the EPP port. In moment, it's not so important the latency (of course that late it will be). And your guess was right, I'm trying to collect real time data!

I hope you can help me! And thanks to try help me!

Edited by lucas89_chuck, 19 January 2009 - 12:50 PM.

  • 0

#4
lucas89_chuck

lucas89_chuck

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts
Sorry, I forgot to say that the Pascal that I'm using is Turbo Pascal Version 7.0 and I'll execute the program on MS-DOS.
  • 0

#5
PaulOF

PaulOF

    Member

  • Member
  • PipPip
  • 20 posts
Hi,
OK, its been a while since I've done any low level DOS programming, so I will need to look up a thing or two. Classes start for me tomorrow so I will be a little busy for the next couple days, but I promise I will get back to you before week's end, hopefully with some help.
Paul
  • 0

#6
lucas89_chuck

lucas89_chuck

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts
Ok, no problem! I'm very thankful for your help! Take the time you need!
  • 0

#7
PaulOF

PaulOF

    Member

  • Member
  • PipPip
  • 20 posts
Hi,
I apologize for being so long in getting back to you, and also for what is, for now, an incomplete answer.

I have been trying without success to find at work a version of Turbo Pascal recent enough to support
assembly language inserts. 5.5 professional would do it, but the latest I have been able to find is the free version of 5.5 that Borland gives away. So, the code that I append here is UNCOMPILED, UNTESTED, and ALMOST CERTAINLY WRONG.
Nonetheless, I suspect it is a good starting point for you.

The two assembly language programs set and clear individual bits in specified device ports. They should be close to correct. The rest of the code concerns itself with saving the old contents of the interrrupt vector, putting the address of the new ISR into the vector, and twiddling bits in the LPT ports and the PIC ports to enable and disable interrupts at appropriate times.

The consts (port number and ISR vector) are based on old memories and are probably wrong.

The lines
Inline($FA); and Inline($FB); respectively turn off and on all maskable interrupts. Therefore whatever
appears between these lines MUST be very short must be re-entrant (i.e. no writelns or any other sort of i/o).

I am not sure how much you know, so I am not sure how much detail to go into... I will continue to look for a compiler that I can debug this on but meanwhile, if you have questions or can't make it work feel free to ask for more help.



Paul

uses

Dos;


const

LptPort = $378;
LptVector = $38;
IRQ = $7;


var

Count : word;
OldISR : pointer;

procedure SetPortBit(Port:Word; Bit:Byte);assembler; {Bit chooses bit to set in port}
{Bit 0 is least significant bit}
asm

mov dx, Port
in al, dx
mov cl, Bit
and cl, 7
mov ah, 1
shl ah, cl
or al, ah
out dx, al

end;

procedure ClearPortBit(Port:Word; Bit:Byte); {as above but clears chosen bit}
assembler;
asm

mov dx, Port
in al, dx
mov cl, Bit
and cl, 7
mov ah, 1
shl ah, cl
not ah
and al, ah
out dx, al

end;

procedure NewISR(Flags,CS,IP,AX,BX,CX,SI,DI,DS,ES,BP:Word)
interrupt;
begin

Inline($FA);
{whatever you want to do here. I am just incrementing a counter}
Count := Count + 1;
SetPortBit(LPTPort + 1, 6);
Inline($FB);

end;

{main}
begin

getIntVec(LPTVector, @OldISR); {save old vector}
setIntVec(LPTVector, @NewISR); {install new vector}

SetPortBit(LPTPort + 1, 6);
SetPortBit(LPTPort + 2, 4);

ClearPortBit($21, 7) {enable inerrupt 7 in PIC}

Count := 0; {counter to count interrupts. Incremented in ISR}
repeat

Write('Interrupt count =');
Writeln(Count);

until KeyPressed;
ReadKey;

SetPortBit($21, 7); {restore PIC}
SetIntVec(LPTVector, @OldISR);

end.



  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP