Board index » delphi » Timer under Windows - Problem!

Timer under Windows - Problem!

I use Turbo/Free Pascal now fow years but,
how can i setup an 44KHz Timer under Windows,
even if i try to set the speed it only runs with 18.2 Hz
... here is a code example ...
procedure mytimer;interrupt;
begin
   { ... }
   port[$20]:=$20;
end;

procedure starttimer(speed:word);
var z:word;
     lz,hz:byte;
begin
   z:=1193180 div speed;
  lz:=lo(z);
  hz:=hi(z);
  asm
    cli
    mov dx,43h;
    mov al,36h
    out dx,al
    mov dx,40h
    mov al,lz
    out dx,al
    mov al,hz
    out dx,al
  end;
  getintvec(8,oldtimer);
  setintvec(8,@mytimer);
  asm sti; end;
end;
.......
starttimer(44000);
......

why dont it work ?

 

Re:Timer under Windows - Problem!


Hello,

Quote
> I use Turbo/Free Pascal now fow years but,
> how can i setup an 44KHz Timer under Windows,
> even if i try to set the speed it only runs with 18.2 Hz

You can't because afair Windows 9x doesn't allow frequencies > 1024 Hz for
DOS box apps.

Regards,
    Thomas

Re:Timer under Windows - Problem!


Any Chance of getting a Frequency at 22 KHz for Example .. (for Sound...i dont
like DMA)

Re:Timer under Windows - Problem!


Quote
dmdeathma...@aol.com wrote:

>I use Turbo/Free Pascal now fow years but,
>how can i setup an 44KHz Timer under Windows,
>even if i try to set the speed it only runs with 18.2 Hz
>... here is a code example ...
>procedure mytimer;interrupt;

It's bad practice to use Turbo's built-in ISR support for hardware ISR's.

Since hardware interrupts can occur asynchronously, there are no guarantees
about the stack.

You should write your hardware ISR's in asm, and switch to an adequately large
local stack before pushing all the registers.

Re:Timer under Windows - Problem!


use $1c as interrupt instead

DMDeathmaker <dmdeathma...@aol.com> wrote in article
<20010616185712.28830.00000...@ng-mi1.aol.com>...

Quote
> I use Turbo/Free Pascal now fow years but,
> how can i setup an 44KHz Timer under Windows,
> even if i try to set the speed it only runs with 18.2 Hz
> ... here is a code example ...
> procedure mytimer;interrupt;
> begin
>    { ... }
>    port[$20]:=$20;
> end;

> procedure starttimer(speed:word);
> var z:word;
>      lz,hz:byte;
> begin
>    z:=1193180 div speed;
>   lz:=lo(z);
>   hz:=hi(z);
>   asm
>     cli
>     mov dx,43h;
>     mov al,36h
>     out dx,al
>     mov dx,40h
>     mov al,lz
>     out dx,al
>     mov al,hz
>     out dx,al
>   end;
>   getintvec(8,oldtimer);
>   setintvec(8,@mytimer);
>   asm sti; end;
> end;
> .......
> starttimer(44000);
> ......

> why dont it work ?

Other Threads