delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/04/30/03:46:14

X-Original-Recipient: djgpp AT delorie DOT com
Message-ID: <MAPI.Id.0016.00333138303633303030303930303110@MAPI.to.RFC822>
X-MSMail-Priority: Normal
X-Priority: 3
To: djgpp AT delorie DOT com
Cc: erik2 DOT berglund AT telia DOT com
MIME-Version: 1.0
From: "Erik Berglund" <erik2 DOT berglund AT telia DOT com>
Subject: Jump from timer interrupt?
Date: (Inget eller ogiltigt datum.)

Hi,         April 30, 2003
I am writing a music sequencer program for DOS using djgpp 2.01
and gcc 2.7.2.1, and it works well. However, I have a small
problem: Because I use my own timer interrupt, 
the PC clock will not be updated during the time I run
the sequencer. Is it possible to jump from my interrupt routine
to the PC timer interrupt once in a while, to update the PC clock
at 18.2 Hz? Or is there another way to solve the problem?
Here is a sample of my code:

#include <dpmi.h>
#include <pc.h>
static int timer;
/*
*  Timer interrupt
*/
void int08() {
   timer++;
/*
*  Is it possible to once in a while
*  jump from here to the standard PC timer interrupt,
*  so the PC clock will be updated to show correct value?
*  If so, how do I do that?
*/
   outportb(0x20,0x20);  /* Send End of Interrupt */
}
int main(int argc,char *argv[]) {
static _go32_dpmi_seginfo oldint08,newint08;
static int i1=0;
/*
*  Init timer interrupts
*/
   _go32_dpmi_get_protected_mode_interrupt_vector(0x08,&oldint08);
   newint08.pm_selector = _my_cs();
   newint08.pm_offset   = (unsigned)&int08;
   _go32_dpmi_allocate_iret_wrapper(&newint08);
   _go32_dpmi_set_protected_mode_interrupt_vector(0x08,&newint08);
   i1 = 1193180.0/480.0;
   outportb(0x40,i1 & 0xff);
   outportb(0x40,i1 >> 8);
/*
*  Run sequencer
*/
   ...
/*
*  Reset timer interrupts
*/
   outportb(0x40,0);
   outportb(0x40,0);
   _go32_dpmi_set_protected_mode_interrupt_vector(0x08,&oldint08);
   _go32_dpmi_free_iret_wrapper(&newint08);
   return(0);
}

Erik Berglund
Gothenbrug, Sweden
erik2 DOT berglund AT telia DOT com


- Raw text -


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