Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to setup an ISR in Turbo C++.

Posted on 1997-08-07
2
Medium Priority
?
844 Views
Last Modified: 2012-08-13
I'm having problems getting my interrupt service routines to work properly. I use the good old Borland TC and follow the examples when setting up my ISR and when saving old vectors and plugging new ones. But still, it doesn't matter how I excite the IRQ-channels, I never manage to enter the ISR. I use IRQ11 on an embedded 386-system. Can you give mee a hint about what could be the problem, I've run out of ideas.

Cheers!
Fredrik Bagenholm
0
Comment
Question by:e92fb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
tomii earned 100 total points
ID: 1252966
Is that int 0x11, or int 11 ?  (hex, or decimal)...

from "Teach Yourself Game Programming in 21 Days", SAMs Publishing... (with some modifications).

note, that if you change MY_INTERRUPT to 0x1C, that is the system timer, & this will update the counter about 18.2 times per second....

#include <dos.h>
#include <bios.h>
#include <stdio.h>
#include <conio.h>

#define      MY_INTERRUPT      0x11  /* int 11 hex */

/* Used to hold the old interrupt vector */
void (_interrupt far *Old_Isr)();

long      counter = 0;      /* global for interrupt to use */

void _interrupt far Count_Ints(void)
{
      /* increment counter whenever interrupt is called */
      counter++;

      /* call the old int handler if there was one (next
            ISR in the chain.  If you want to disable the
            other interrupts (no chain), then do not
            call this next function... WARNING!!  you
            can mess things up doing this, as some
            system processes _need_ some interrupts! */

      Old_ISR();
}

void main()
{
      /* save old ISR */
      Old_Isr = _dos_getvect(MY_INTERRUPT);

      /* install my ISR */
      _dos_setvect(MY_INTERRUPT, Counter);

      /* wait for keyhit */
      while(!kbhit())
      {
            /* print current value of counter - note that it
            is being changed by th ISR */
            printf("The ISR has been called %ld times", counter);

      }

      /* Replace the old ISR */
      _dos_setvect(MY_INTERRUPT, Old_Isr);

}
0
 

Author Comment

by:e92fb
ID: 1252967
Hi and thanks!
I've actually managed to get it going, but I had to change the IRQ-mask to enable IRQ10 and IRQ11. This wasn't done by BIOS at start-up as I expected. Also an EOI has to be sent (both to address 0xA0 and 0x20) to the PIC just before leaving the ISR.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question