how do i find out the CLK input of the system timer?
my motherboard is 81845gvm-rz with intel 845gv chipset.the CPU is pentium 4 533/400mhz fsb
in the user's manual there's a block diagram for the clock generator and it has 10 output lines:
1.PCICLK(33MHZ)
2.USBCLK(48MHZ)
3.14.318MHZ
4. 33MHZ
5. 24MHZ
6.MCHCLK +/-(100/133MHZ)
7.CPUCLK +/-(100/133MHZ)
8.AGPCLK(66MHZ)
9.GMCHCLK(66MHZ)
10.ICH3V66(66MHZ)
i don't know which out is for the system timer.plz help
thanks
The standard clock for the system timer runs at 1,193,182 Hz, derived for the original IBM PC as the 4.77 MHz processor clock divided by 4. I doubt that your system uses a different clock speed, but you can test it, under Windows 9x or under MS-DOS only, with this DOS program. Note that system timer 2 is not available under Windows 2000 or XP, so this program will not delay.
;--------------------------------------------------------------
; If the system timer clock is somewhere close to 1,193,182Hz,
; This program should delay 10 seconds between prompts.
;--------------------------------------------------------------
.model small
.386
.stack
.data
tobegin db "Press any key to begin",13,10,"$"
finished db "Finished, press any key to exit",13,10,"$"
.code
.startup
; Set the gate for timer 2 (bit 0 at I/O port 61h) to off.
; To avoid changing other bits in the register, read the
; current value, set bit 0, and write the altered value
; back.
mov dx,61h
in al,dx
and al,NOT 1
out dx,al
; Program timer 2 for LSB then MSB, mode 0, binary.
; The system timer control word register is at I/O
; port 43h. The system timer control word is set as
; follows:
; bit 7-6: 10 = timer 2
; bit 5-4: 11 = R/W LSB then MSB
; bit 3-1: 000 = single timeout
; bit 0: 0 = binary
mov dx,43h
mov al,0b0h
out dx,al
; The system timer normally has a 1,192,182Hz clock.
; For a full timer cycle you load an initial count
; of zero, which, because the count is decremented
; before it is checked for zero, causes the timer
; to count 65,536 clock cycles before it times out.
; Each cycle with take 65536/1192183 ~ 55ms, so
; 182 cycles should take ~10 seconds.
mov ah,9
mov dx,OFFSET tobegin
int 21h
mov ah,0
int 16h
mov cx,182
looper:
; Load the starting value, LSB then MSB.
mov dx,42h
mov al,0
out dx,al
out dx,al
; Set the gate for timer 2 (bit 0 at I/O port 61h) to on.
mov dx,61h
in al,dx
or al,1
out dx,al
; Wait until the output bit (bit 5 at I/O port 61h) is set.
@@:
in al,dx
and al,20h
jz @B
loop looper
mov ah,9
mov dx,OFFSET finished
int 21h
mov ah,0
int 16h
.exit
end
MAKEIT.BAT:
ML /c timer.asm
PAUSE
LINK16 timer.obj;
my os is windows XP and i ran it from the command prompt and it did not delay.so i guess this program won't delay even if it was run ifrom the command prompt.
anyway:
1." ; Wait until the output bit (bit 5 at I/O port 61h) is set.
@@:
in al,dx
and al,20h
jz @B "
what's the reason for waiting bit 5?is it because it changes it's state every 15.085microseconds?according to my book,it is bit 4 that changes it state every 15.085 microseconds.what is ur comment?
2.accoding to my book,this is the code to generate a 10 second time time delay.it only uses port 61h.any comment?
.MODEL SMALL
.STACK 64
.386
.DATA
tobegin db "Press any key to begin",13,10,"$"
finished db "Finished, press any key to exit",13,10,"$"
.CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
mov ah,9
mov dx,OFFSET tobegin
int 21h
mov ah,0
int 16h
sub bx,bx
mov bl,48
again: mov cx,55260
call delay
dec bl
jnz again
mov ah,9
mov dx,OFFSET finished
int 21h
mov ah,0
int 16h
MOV AH,4CH
INT 21H
MAIN ENDP
DELAY PROC
PUSH AX
WAITF1: IN AL,61H
AND AL,10H
JE WAITF1
MOV AH,AL
LOOP WAITF1
POP AX
Ret
DELAY EndP
END MAIN
3.why did you load counter 2 with mode 0?
thnak you
Bit 5 of I/O port 61h is the output for timer 2, and bit 4 is the output for timer 1.
I used mode 0, Single Timeout, because it is suitable for creating a short programmable delay, which is what I originally used the code for. I simply adapted existing code as a crude method of checking the system timer clock speed.
I recall trying to use timer 1 to create a programmable delay for DOS programs running under Windows 2000/XP, but I ended up using a different method because the output of timer 1 is far too erratic for short delays under Windows 2000/XP. I suspect that the output you see is just some crude emulation that Microsoft provided to support some common application that depended on it. The code below will delay for 10 seconds when run from a Windows 9x boot disk, but the delay is more like 8 seconds under Windows 2000.
;--------------------------------------------------------------
; If the system timer clock is somewhere close to 1,193,182Hz,
; this program should delay 10 seconds between prompts.
;
; System timer 1 was originally used to generate periodic DRAM
; refresh requests. It is normally programmed to operate in
; mode 2 and loaded with an initial count of 18. This causes
; it to cycle once each 18/1193182 = 15.086 microsecond and
; drive bit 4 of I/O port 61h low for a period of 1 count
; (1/1193182 = 838 nanosecond).
;--------------------------------------------------------------
.model small
.386
.stack
.data
tobegin db "Press any key to begin",13,10,"$"
finished db "Finished, press any key to exit",13,10,"$"
.code
.startup
mov ah,9
mov dx,OFFSET tobegin
int 21h
mov ah,0
int 16h
mov ecx,10*1193182/18
mov dx,61h
looper:
in al,dx
and al,10h
mov ah,al
@@:
in al,dx
and al,10h
cmp ah,al
je @B
loopd looper
mov ah,9
mov dx,OFFSET finished
int 21h
mov ah,0
int 16h
.exit
end
MAKEIT.BAT:
ML /c timer.asm
PAUSE
LINK16 timer.obj;
thanks alot.very helpful info