Mail Archives: djgpp/2001/10/26/05:05:08
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.
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 -