• C

How to setup an ISR in Turbo C++.

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
e92fbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tomiiCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
e92fbAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.