delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/10/13/10:16:30

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: ahenric AT ccii DOT co DOT za (Arne)
Newsgroups: comp.os.msdos.djgpp
Subject: Speeding up timer
Date: 13 Oct 2003 07:06:43 -0700
Organization: http://groups.google.com
Lines: 33
Message-ID: <e74abcbf.0310130606.19aee3c@posting.google.com>
NNTP-Posting-Host: 196.30.62.5
X-Trace: posting.google.com 1066054003 6644 127.0.0.1 (13 Oct 2003 14:06:43 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Mon, 13 Oct 2003 14:06:43 +0000 (UTC)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

How can I speed up the timer so that my signal handler (on SIGALRM) is
called more often than the default 18.2Hz?

I have tried to reprogram the 8254 PIT, but that doesn't do anything.
Here is my code:

/* timer struct */
struct itimerval timeout;

void tickSignal()
{
  counter++;
}

/* set tick interrupt to 200Hz */
outportb(0x43, 0x36);
outportb(0x40, ((1193180L / 200) & 0x00ff));
outportb(0x40, (((1193180L / 200) >> 8) & 0x00ff));


/* Initialise timer structure */
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_usec = 5000;
timeout.it_value.tv_sec = 0;
timeout.it_value.tv_usec = 5000;

__djgpp_clock_tick_interval = 5000;

signal(SIGALRM, tickSignal);
setitimer(ITIMER_REAL, &timeout, NULL);

Thanks
Arne

- Raw text -


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