Programming Interrupt Controller for Clock's specified freq
Posted: Sun Nov 10, 2013 11:19 am
Hey,
I have got a problem with timer (8253) to set interrupts correctly. I want to run interrupt with frequency 20Hz, so it means I want specified procedure to be run 20 times per second.
Here are steps I have done so far:
Programming Interrupt Controller:
Configure clock:
I want to run 8253 with 20Hz so I set timer with value 1193181/20=59659,05. Remove .05 part and set timer value to 59659 (dec) = 1110100100001011 (bin) and my code is:
My IDT entry for clock is set like:
and then i set base address whichc is set properly becouse i have checked it at bochs, screen:
http://s24.postimg.org/g9chkxmg5/clock86.jpg (interrupt number 31 = 20h)
It's set correcly, nasm output:
After I run bochs i set break point to 0x8151 (0x8000 is base of my CS segment) (using 'lb 0x8151' command)
Then I press "continute" and no interrupt from 8253 clock come, but when i break i see ebx register increasing very fast like about 300 (dec) per second. Anyway it's definitly too fast it should increase 20 (dec) per second.
Why breakpoint for 0x8151 is not working ? It seems to be executed anyway, why ?
Why is it increasing EBX register for 300 +/- (dec) per second, not 20 per second ?
Hope you will be able to help me, becouse I have no idea where is mistake.
Thank you for help.
I have got a problem with timer (8253) to set interrupts correctly. I want to run interrupt with frequency 20Hz, so it means I want specified procedure to be run 20 times per second.
Here are steps I have done so far:
Programming Interrupt Controller:
Code: Select all
MOV DX,20H ;init
MOV AL,11H ;icw1=11h
OUT DX,AL
INC DX
MOV AL,20H ;icw2=20h (interrupt vector's offset)
OUT DX,AL
MOV AL,4 ;icw3=04h (master system)
OUT DX,AL
MOV AL,1 ;icw4=01h (mode 8086/88)
OUT DX,AL
MOV AL, 0xfc ;ocw1=0fdh (interrupt mask - master)
OUT DX,AL
MOV DX,0A1H ;mask interrupt– slave
MOV AL,0FFH
OUT DX,AL
Configure clock:
Code: Select all
MOV AL, 00110100B
OUT 43H, AL
Code: Select all
MOV AL, 000001011b
OUT 40H, AL
MOV AL, 011101001b
OUT 40H, AL
Code: Select all
dw 0
dw 8
db 0
db 010001110b
dw 0
http://s24.postimg.org/g9chkxmg5/clock86.jpg (interrupt number 31 = 20h)
It's set correcly, nasm output:
And it seems it's all my code for it.207 interruptt0:
208 ;mov eax, 14h
209 00000151 43 inc ebx
210
211 00000152 B060 mov al, 0x20 ; tell pic that interrupt
212 00000154 E620 out 0x20, al ; was served
213 00000156 CF iret
After I run bochs i set break point to 0x8151 (0x8000 is base of my CS segment) (using 'lb 0x8151' command)
Then I press "continute" and no interrupt from 8253 clock come, but when i break i see ebx register increasing very fast like about 300 (dec) per second. Anyway it's definitly too fast it should increase 20 (dec) per second.
Why breakpoint for 0x8151 is not working ? It seems to be executed anyway, why ?
Why is it increasing EBX register for 300 +/- (dec) per second, not 20 per second ?
Hope you will be able to help me, becouse I have no idea where is mistake.
Thank you for help.