delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/26/22:34:22

From: "Alexander Russell" <alexander DOT russell AT telus DOT com>
Newsgroups: comp.os.msdos.programmer,comp.os.msdos,comp.os.msdos.djgpp,comp.os.msdos.misc
References: <bf50ce95 DOT 0110242053 DOT 1568dcea AT posting DOT google DOT com> <B9NB7.30940$%K4 DOT 5763583 AT news1 DOT telusplanet DOT net> <bf50ce95 DOT 0110260054 DOT 1153f72a AT posting DOT google DOT com>
Subject: Re: Control timing
Lines: 122
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
Message-ID: <eRoC7.38433$%K4.6914940@news1.telusplanet.net>
Date: Sat, 27 Oct 2001 02:19:54 GMT
NNTP-Posting-Host: 142.179.73.197
X-Trace: news1.telusplanet.net 1004149194 142.179.73.197 (Fri, 26 Oct 2001 20:19:54 MDT)
NNTP-Posting-Date: Fri, 26 Oct 2001 20:19:54 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"jeffchan" <jeffkhc AT netvigator DOT com> wrote in message
news:bf50ce95 DOT 0110260054 DOT 1153f72a AT posting DOT google DOT com...
> Thanks your kindly information.
>
> I use this code and having modification to verify the performance when
> i make it faster.
>
> My testing is checking the reading of x after certain time.
> For 1kHz, that's okay. For 8kHz, the result is the same as 1kHz.

AJR - I don't see an obvious problem. Are you running under DOS? If running
under a dos box in win9x the timing will not be exactly what you expect.

>
> What's the problem?
>
> /**************************************/
> #include <stdio.h>
> #include <stdlib.h>
> #include <dos.h>
> #include <bios.h>
> /******************function prototype*******************************/
> void init_timer(void);
> void deinit_timer(void);
> static void interrupt new_timer(void);
> /*******************************main********************************/
> unsigned long x=0;
> int main(){
> init_timer();
> while( !bioskey(1) ){
> }
> deinit_timer();
>         printf("\n%ld", x);
> return 0;
> }
> /**************************************************************/
> /* ---------------------- new_timer() -------------------*/
> static void interrupt new_timer(void){
>     asm cli
>     x++;
>     // reset PIC
>     asm {
> mov al, 20h
>         out 20h, al
>     }
>    asm sti
> }
> /*********************************************************************/
> /* ---------------------- init_timer() ------------------ */
> void init_timer(void){
> oldtimer=getvect(8); // save old timer
> asm cli
> // speed up clock
> asm {
> mov bx, 149   //set the clock to 8kHz
>                                   //1193180/8kHz=149
> mov     al, 00110110b
> out     43h,al
> mov     al, bl
> out     40h, al
>             mov     al, bh
> out     40h, al
> }
>     setvect(8, new_timer);
> asm sti
> }
> /* ---------------------- deinit_timer() ---------------- */
> void deinit_timer(void){
> asm cli
> // slow down clock   1193180 / 65536 = 18.2, but we use zero
> asm {
>     xor bx, bx          // min rate 18.2 Hz when set to zero
>         mov al, 00110110b
>     out  43h, al
>     mov al, bl
>         out  40h, al
>     mov  al, bh
>     out  40h, al
>         }
> setvect(8, oldtimer);  // restore oldtimer
> asm sti
> }
>
>
>
>
>
> "Alexander Russell" <alexander DOT russell AT telus DOT com> wrote in message
news:<B9NB7.30940$%K4 DOT 5763583 AT news1 DOT telusplanet DOT net>...
> > "jeffchan" <jeffkhc AT netvigator DOT com> wrote in message
> > news:bf50ce95 DOT 0110242053 DOT 1568dcea AT posting DOT google DOT com...
> > > Hi,
> > >
> > > now an external data is fed into a capture card and i need store the
> > > captured data into hard drive. The capture card is controlled under
> > > msdos and my control program is written by turbo c.
> > >
> > > The sampling rate is expected around 8kHz per channel. Now i want to
> > > create 8, 16 or 32 channels. Polling method with looping delay to each
> > > channel i use in currently because the card can't capture different
> > > channels at the same time.
> > >
> > > However, i find that the timing is difficult to control.
> > >
> > > Any suggestion or improvement advice?
> > >
> > > Is using timer interrept possible? If yes, any information about it,
> > > such as interrupt number, or how fast of that timer, etc.?
> > > (Actually i find that int 0x1C isn't fast enough to do that, only
> > > 18.25Hz)
> > >
> > > Jeff
> >
> > You can reprogram the timer to run faster. A sample is in common.zip at
> > http://www3.telus.net/alexander_russell
> > see timer.c, speed up the timer, and install a simple ISR
> >
> > The faq for comp.os.msdos.programmer (use google or get from the group)
has
> > good information on timing under DOS.


- Raw text -


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