using CMOS timer? [FIXED]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

using CMOS timer? [FIXED]

Post by earlz »

[Fix is at bottom]
Well, I am designing this OS that actually does need 2 timers. (one to run another OS code, one for the hypervisor)

I have been trying to get CMOS timer to work(irq 8) but it has yet to..
I am using info I found at http://www.nondot.org/sabre/os/files/Mi ... Timer.html and http://www.ousob.com/ng/interrupts_and_ ... g9116b.php

My code just does

Code: Select all

int timer_Init(){
	InstallInterruptHook(IRQ_BASE_INT+8,&timer_Irq0Handler);
	outportb(0x70, 0x0B);
	int prev=inportb(0x71);
	outportb(0x70,0x0B); //a read will reset index
	outportb(0x71, prev | 0x44);
	
	return 0;
}
When I run the code though, the interrupt is only ran once, then never happens again.

Edit:
that edit was wrong
(also edited my current code)

[FIXED]
Ok, I figured out my problem that neither of the previous sources told me. The more useful source is http://www.geocities.com/SiliconValley/ ... s/rtc2.htm
At the IRQ8 handler, you must read status register C. Otherwise an interrupt will not occur again.
I have also noticed that sometimes that the CMOS clock produces much more reliable clock result between computers. Where as with the PIT on some simulations it would be extremely fast, on some computers it would be fast, and on some slow..
Post Reply