Date: Sun, 2 Apr 2000 09:38:35 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Michal Strelec cc: djgpp AT delorie DOT com Subject: Re: PmComm and 2 coms In-Reply-To: <8bn0jc$dq3$1@ns.felk.cvut.cz> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 27 Mar 2000, Michal Strelec wrote: > 1. After interrupt (from COM1) ocuare and interrupt routin is called is > automaticly other COM1 (or COMs) or every interrupt disabled? COM2's IRQ is higher priority than COM1's IRQ. So whenever the COM2 handler is invoked, COM1 interrupts will be suspended until you send the EOI command to the Interrupt Controller. In contrast, COM2 interrupts can interrupt the COM1 handler, unless you call `disable' inside the handler. Other than that, I don't think interrupts are disabled when you enter the handler. > 2. When used "disable()" it is compiled in assembler as "cli", does it > disable all hardware interrupts? It depends on the OS. On MS-DOS, typically all interrupts are disabled, on Windows only the current DOS box doesn't receive any interrupts. > 3. When used "enabled()" when exactly is interrupt enabled? After execution > of NEXT intruction or imidiatly after enabled (sli instruction)? I think the interrupts are enabled after STI. > My program maintance 2 COMs. I have installed 1 PM timer interrupt, 2 PM > communications interrupt routines. > Evrything works when communication is just on one port, but when I have > connected to my computers two others and is some traffic from each one. The > systems crashs. > I was completly lost so I put there some printf commands (I know it should > be but I was lost). And systems works something like this. > When crash ocuare system do this: > interrupt from COM2 ocuare and interrupt routin is called BUT know interrupt > from COM1 occuare ... before COM2 routine is finished. But it should NEVER > do it. Because it is locked. Really don't get it. Sorry, I don't follow this description. Please try to elaborate. > 3. and have function CommIntr which maintaince all interrupts whitch never > should appeares in one time. > > void CommIntr(char com,int nEvent) { > int ret,channel; > char c; > > /* First check out what chennel is it */ > for (channel=0;channel<4;channel++) > if (COM[channel]==com) > break; > /* Now variable channel means channel */ > > switch (nEvent) { > case evCOMRx: > /* Receive byte interrupt */ > COMReadChar(com,&c,NULL); > Receive(channel,c); > break; > case evCOMTx: > /* Transmited byte interrupt */ > ret = Send(channel); > if (ret!=-1) > COMWriteChar(com,(unsigned char)ret,NULL); > } > } It is very hard to follow this, since you only posted part of the code, and I'm not familiar with the details of the library you are using. However, in general, it is very dangerous to leave the COMx interrupts enabled when you transmit characters, because you may get another interrupt before leaving the handler, once the UART transmit register is empty. I suggest trying the program in receive-only mode, to see whether the crashes go away; if they do, it might well be that interrupt-driven transmission drives your program nuts. In that case, disabling the interrupts from the COM ports for the entire duration of CommIntr and re-enabling them before you send the EOI to the Interrupt Controller might solve the problem. Btw, the above code doesn't seem to send the EOI command. Where is it?