home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.ibm.pc.hardware:24131 comp.sys.ibm.pc.programmer:412
- Newsgroups: comp.sys.ibm.pc.hardware,comp.sys.ibm.pc.programmer
- Path: sparky!uunet!mcsun!sun4nl!dutrun!donau!zen!wolff
- From: wolff@zen.et.tudelft.nl (Rogier Wolff)
- Subject: Serial line interrupts.
- Message-ID: <1992Sep13.093415.10243@donau.et.tudelft.nl>
- Originator: wolff@zen.et.tudelft.nl
- Sender: news@donau.et.tudelft.nl (UseNet News System)
- Nntp-Posting-Host: zen.et.tudelft.nl
- Reply-To: wolff@zen.et.tudelft.nl (Rogier Wolff)
- Organization: Delft University of Technology, Dept. of Electrical Engineering
- Date: Sun, 13 Sep 1992 09:34:15 GMT
- Lines: 115
-
-
- Hi everyone,
-
- I'm trying to make a simple program using interrupts to read the serial
- ports. However it seems as if I can't get the interrupts enabled to such
- a level that my interrupt routine gets called. Does anybody out there know
- any other bits that I should twiddle before I can receive interrupts?
- (I had expected some trouble in getting the write interrupt to work,
- turning it on and off at the rigth time. However I don't get any interrupts
- at all!)
-
- The interrupt handling part of the program is below, the rest is
- chopped off for brevity. (Yes I _do_ call initirq)
-
-
- #include <dos.h>
-
- #define BUFSIZE 128
-
- #define READ_READY 0x01
- #define WRITE_READY 0x20
-
- static int wqis=BUFSIZE,wqos=0;
- static char wq[BUFSIZE];
- static int wqhead=0;
- static int wqtail=0;
-
- static int rqis=BUFSIZE,rqos=0;
- static char rq[BUFSIZE];
- static int rqhead= 0;
- static int rqtail= 0;
-
- int base = 0x2f8;
-
- interrupt anyint (void);
- void read_int (void);
- void write_int (void);
-
- static int test=0;
-
- void initirq (int port)
- {
- union REGS inregs,outregs;
- struct SREGS sregs;
-
- static int bases[]= { 0x3f8,0x2f8,0x3e8,0x2e8};
- #define IRQNUM 3
- base = bases[port-1];
-
- inregs.h.ah = 0x25;
- inregs.h.al = 0x0b;
- inregs.x.dx = FP_OFF (anyint);
- segread (&sregs);
- sregs.ds = FP_SEG (anyint);
- intdosx (&inregs,&outregs,&sregs);
- /* *(long *) (MK_FP(0,0xb*4)) = anyint; */
- outportb (base+1,03);
- outportb (0x21,1 << IRQNUM);
- }
-
- void ackit (int irq)
- {
- int tmp;
- static int t;
-
-
- tmp = inportb (0x21);
- t++;t++;
- outportb (0x21,tmp | (1<< irq));
- t++;t++;
- outportb (0x20,0x20);
- }
-
- void unblk (int irq)
- {
- int tmp;
- static int t;
-
- tmp = inportb (0x21);
- t++;t++;
- outportb (0x21, tmp & ~(1<< irq));
- }
-
- interrupt anyint ()
- {
- int st;
-
- /* I know, I shouldn't use printf in interrupts: it crashes the machine.
- Which is the effect I hoped to provoke... */
- /*printf ("Hello world! \n"); */
- test++;
- ackit (3);
- st = inportb (base+5);
- if (st & WRITE_READY)
- write_int ();
- if (st & READ_READY)
- read_int ();
- unblk (3);
- return 0;
- }
-
-
- void disablewirq (void)
- {
- outportb (base+1,01);
- }
-
- void restartirq (void)
- {
- outportb (base+1,03);
- }
-
- --
- **** a 486 in V86 mode is like a VW buggy with a 6 litre V12 motor. ****
- EMail: wolff@duteca.et.tudelft.nl ** Tel +31-15-783644 or +31-15-142371
-