www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/19/15:04:15

From: Peter Gober <gober AT exp-math DOT uni-essen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Parallel port/Interrupt handling - please help me
Date: Sun, 19 Jan 1997 15:57:03 +0100
Organization: University of Essen, Digital Communications Group
Lines: 60
Message-ID: <32E2363F.41C6@exp-math.uni-essen.de>
NNTP-Posting-Host: 132.252.150.40
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello everybody,

I want to implement a serial interface with an external clock using a
standard parallel interface. I want to do that with interrupts and used
DJGPP and a protected mode handler written in C. But it doesn't work.
After working for more than two days now, I hope that maybe someone can
give me a hint.

I have enclosed a reduced version of my program. I would expect it to
count my clocks, which it doesn't. I use MS-DOS 6.22 with HIMEM and
EMM386. The clock is about 2 kHz and on the ACK-Line of the parallel
interface. I use IRQ5 and port address 0x3bc. With an oscilloscope I
checked that the IRQ5 line oscillates. Some software things happen too,
because if I increase the clock frequency very much, my program becomes
slower. I know I used the correct port address, because if I read the
ACK input it oscillates too.  I have a network card in the computer, but
no sound card (these shouldn't be the problem, should they?)

Obviously my handler isn't called.

I would be really very thankful if someone could give me a hint.

Peter
------------------------------------------------------------------------
#include <dpmi.h>
#include <crt0.h>
#include <pc.h>

static const short lptBaseAddr = 0x3bc;
static const short lptIRQ = 5;

int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; /* no paging */

static unsigned int counter = 0;

static void intHandler(void) {
        counter++;
}

static _go32_dpmi_seginfo info;
                                        
main() {
        /* don't generate interrupts */
        outportb(lptBaseAddr+2, 0); 

        /* change handler */
        info.pm_offset = (int) intHandler;
        info.pm_selector = _go32_my_cs();
        _go32_dpmi_allocate_iret_wrapper(&info);
        _go32_dpmi_set_protected_mode_interrupt_vector(lptIRQ, &info);

        /* enable interrupt in interrupt controller */
        outportb(0x21, inportb(0x21) & (~(1 << lptIRQ)));
        /* generate interrupts */
        outportb(lptBaseAddr+2, 0x10);

        for(;;) {
                printf("counter: %d\n", counter);
        }
}

- Raw text -


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