IRQ0 ? How would I setup the clock?

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
gtsphere

IRQ0 ? How would I setup the clock?

Post by gtsphere »

I have read a lot about the IRQ0 but how would I actually go about setting it up in C? I have pretty lost with that right now, i've viewed other peoples but it doesn't really just answer, how can i get a simple clock, like that just counts seconds, no hours, etc?
Tim

Re:IRQ0 ? How would I setup the clock?

Post by Tim »

Set up your IDT. Write some assembly code which will save registers, call a C function, then restore registers. Write a handler for IRQ 0 which looks like:

Code: Select all

void irq0_handler(void)
{
    elapsed_ticks++;
}

unsigned get_system_uptime(void)
{
    // assumes default rate of 18.2 Hz (91/5 = 18.2)
    return (elapsed_ticks * 5) / 91;
}
There are examples elsewhere of how to set up an IDT, write interrupt wrapper routines, and change the clock rate.
Tom

Re:IRQ0 ? How would I setup the clock?

Post by Tom »

does that update_time...thing return in seconds?
Tom

Re:IRQ0 ? How would I setup the clock?

Post by Tom »

oh it does....( I think by now I should Remember to read better )
Post Reply