From: XXguille AT XXiies DOT XXes (Guillermo Rodriguez Garcia) Newsgroups: comp.os.msdos.djgpp Subject: Re: înterrupt problem Date: Thu, 13 May 1999 11:12:28 GMT Organization: Telefonica Transmision de Datos Lines: 88 Message-ID: <373c1ba7.3760034@noticias.iies.es> References: <7hcnbo$j0t$1 AT news DOT dnsg DOT net> NNTP-Posting-Host: iies196.iies.es Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: Forte Agent 1.5/32.451 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com El día Wed, 12 May 1999 22:11:31 +0200, "Daniel Kadenbach" escribió: >Hi all ! > >I am just trying to program a serial-port-interface (via uart-programming) >and therefore need to bend the >irq of the com2 port to my own function, but i don´t get it to work ... Some ideas: - Make sure the desired interrupt is enabled in the PIC (programmable interrupt controller) - Make sure interrupts are enabled (use enable() for that) - Make sure you allow UART interrupts by setting the relevant bits of the appropiate UART register. These are MCR (Modem Control Register) and IER (Interrupt Enable Register). - In your interrupt handler, acknowledge the interrupt by reading from the appropiate UART register (for example, if you interrupt was caused by a change in the MSR, you should read the MSR until less significant bit of IIR is set). If you are still stuck, drop me a line and I will post some example code. >My code looks like this: > > new_handler.pm_offset = (int)int_uart; > new_handler.pm_selector = _go32_my_cs(); > _go32_dpmi_get_protected_mode_interrupt_vector(0xb, &old_handler); > _go32_dpmi_allocate_iret_wrapper(&new_handler); > _go32_dpmi_set_protected_mode_interrupt_vector(0xb,&new_handler); Everything is OK here. >the Interrupt function: > >static int int_uart( void ) I would declare an interrupt handler as returning void, not int, but I guess that this will work as well. >{ > asm("cli; pusha"); You don't need this! You allocated an iret_wrapper which will do all the work of pushing / poping registers and the like. I think you still need the EOI at the end of your function, but I'm not sure. Try this: #define COM_RBR (COMbase + 0x00) #define COM_IIR (COMbase + 0x02) #define COM_LSR (COMbase + 0x05) #define COM_MSR (COMbase + 0x06) static void int_uart(void) { /* Acknowledge the interrupt by reading from the * appropiate UART registers. The following piece * of code acknowledges _all_ possible interrupt * sources. */ while ((inportb(COM_IIR) & 0x01) == 0x00) { inportb(COM_LSR); inportb(COM_RBR); inportb(COM_MSR); } /* Here goes your code */ test++; /* Issue an EOI to the PIC and exit */ outportb(0x20, 0x20); return; } Regards, GUILLE ---- Guillermo Rodriguez Garcia XXguille AT XXiies DOT XXes (ya sabes :-)