delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/01/23:17:59

From: Erik Berglund <erik2 DOT berglund AT telia DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Interrupts on EPP-port
Lines: 134
Message-ID: <Ddcv4.1077$y3.193767424@newsb.telia.net>
Date: Wed, 01 Mar 2000 17:14:11 GMT
NNTP-Posting-Host: 194.237.157.157
X-Complaints-To: abuse AT telia DOT com
X-Trace: newsb.telia.net 951930851 194.237.157.157 (Wed, 01 Mar 2000 18:14:11 CET)
NNTP-Posting-Date: Wed, 01 Mar 2000 18:14:11 CET
Organization: Telia Internet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

David Hallberg <david DOT hallberg AT data DOT ing DOT hb DOT se> write: 
> I'm having problem with getting my program to trigger on interrupts
> from the parallel port (EPP-mode)
> it works just fine when triggering from the timer, keyboard, and even
> the networkcard (I have tried to switch IRQ between the networkcard and 
> the parallel port, but it still only trigger in the network card and not
> the parallel port)
> I have read the discussion from 1998 initialized by  "Michel Gallant"
> <mgallant AT NOSPAM DOT grassroots DOT ns DOT ca> 
> about this,  but could not find any final, working example.
> 
> Code:
> 
> #include  <dpmi.h>
> #include  <stdio.h>
> #include  <unistd.h>
> #include  <pc.h>
> #include  <termios.h>
> 
> //#define VECTOR 8  // Timer
> #define VECTOR 9  // keyboard
> //#define VECTOR 13 // LPT2     IRQ 5
> //#define VECTOR 15 // LPT1   IRQ 7
> 
> 
> #define SET_BIT(x, b)   ((x) |= (1 << (b)))
> #define CLEAR_BIT(x, b) ((x) &= ~(1 << (b)))
> #define EPPADRESS 0x278
> 
> volatile int tics = 0;
> unsigned int i, ii, inter = 0;
> unsigned char regbyte, adr21;
> unsigned long time1, time2;
> 
>      tic_handler()               // Interrupthandler
>      {
>        tics++;
>      }
>      
>      int main()
>      {
>        _go32_dpmi_seginfo old_handler, new_handler;     // Structs for
> handler
> 
>        new_handler.pm_offset = (int)tic_handler;        // give the
> struct the new handler
>        new_handler.pm_selector = _go32_my_cs();         // and a pointer
> to this code
> 
>        printf("\nGrabbing interrupts");
>                                                         // Reading old
> handler
>        _go32_dpmi_get_protected_mode_interrupt_vector(VECTOR,
> &old_handler);
> 
>        _go32_dpmi_allocate_iret_wrapper(&new_handler);   // makes the
> overhead for interrupthandeler
>                                                         // Struct is the
> new handler
>        _go32_dpmi_set_protected_mode_interrupt_vector(VECTOR,
> &new_handler);
>        //_go32_dpmi_chain_protected_mode_interrupt_vector(VECTOR,
> &new_handler);
> 
>        printf("\nStatusreg  %#x", inportb(EPPADRESS + 1));
>        printf("\nControlreg %#x", inportb(EPPADRESS + 2));
> 
>        regbyte = inportb(EPPADRESS + 2);                       //
> reading printerports old controll reg
>        SET_BIT(regbyte , 4);    // enable intr. from port
> 
>        outportb(EPPADRESS + 2 , regbyte);       // writing the modified
> reg.
> 
>        printf("\nStatusreg  %#x", inportb(EPPADRESS + 1));
>        printf("\nControlreg %#x", inportb(EPPADRESS + 2));
>        inter = enable();                    // enabeling interrupts
> 
> 
>        time1 = rawclock();                       // get the current time
>        tics = 0;
>        while( tics < 1){}                        // wating for one
> interrupt
>        time2 = rawclock();
>        printf("\nNumber of Interrupts during the execution: %d ", tics);
>        printf("\nTime1: %D",time1);
>        printf("\nTime2: %D",time2);
>        printf("\nDIFF : %D",time2 - time1);
>                                                  // puting back the old
> handeler
>        _go32_dpmi_set_protected_mode_interrupt_vector(VECTOR,
> &old_handler);
>        _go32_dpmi_free_iret_wrapper(&new_handler);
>        getkey();
>        return 0;
> 
>      }

I once wrote a 16-bit Turbo Pascal program for 
Voyetra VP-11 MIDI interface, which was connected to 
the printer port, and using IRQ7.

To get it working, I had to set the IRQ enable bit
(bit 4) in the printer control register, and also
send a special initial string of bytes to the VP-11.

After writing a byte to the VP-11, I sent 0xf5 and
0xf4 to the printer control register, in order to
toggle bit 0 (Write Acknowledge), but this is
probable not needed in your case.  Before writing
next byte, I inserted a 0.4 ms delay (MIDI byte
transmission time).

Upon receiving a MIDI byte, the VP-11 sent an
IRQ7 to the PC.  After reading the MIDI byte from
the VP-11, I sent 0xf6 and 0xf4 to the printer
control register, in order to toggle bit 1 
(Read Acknowledge), which is probably not needed 
in your case either.

Just a thought: Did you unmask IRQ7 and IRQ5 in the
interrupt controller?  (outportb(0x21,inportb(0x21) & 0x5f))

Maybe you should send End Of Interrupt (outportb(0x20,0x20))
before interrupt return, but I think the iret wrapper
will do that for you.

Hope this helps,

--
Erik Berglund
erik2 DOT berglund AT telia DOT com


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019