From 7e81739528577c2e7f92b42b2d186b63fdd3d6d5 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 2 Oct 2019 20:40:09 +0200 Subject: Made timer more precise --- src/kernel/timer/timer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/kernel/timer/timer.c') diff --git a/src/kernel/timer/timer.c b/src/kernel/timer/timer.c index f332429..7d650e8 100644 --- a/src/kernel/timer/timer.c +++ b/src/kernel/timer/timer.c @@ -4,13 +4,13 @@ static unsigned int timer_ticks = 0; void timer_phase(int hz) { - int divisor = 1193180 / hz; + int divisor = (int) (3579545.0 / 3.0 / (double) hz); send_b(0x43, 0x36); // 01 10 11 0b // CTR, RW, MODE, BCD send_b(0x40, divisor & 0xFF); send_b(0x40, divisor >> 8); } -// Executed 100 times per second +// Executed 1000 times per second void timer_handler(struct regs *r) { timer_ticks++; } @@ -31,6 +31,6 @@ unsigned int get_time() { // Install timer handler into IRQ0 void timer_install() { - timer_phase(100); + timer_phase(1000); irq_install_handler(0, timer_handler); } \ No newline at end of file -- cgit v1.2.3