Page 1 of 1

IRQ 8 triggered only once

Posted: Tue Nov 27, 2007 6:02 pm
by Dandee Yuyo
This must be very basic, but I cannot make it work :cry:

I get only one interrupt after enabling it.

This is what I'm doing:

Enable PIE bit on the MC146818A chip:
// ! assumes interrupts are disabled
outportb(0x70, 0x0b); // choose RTC register 11
int regB = inportb(0x71);
outportb(0x70, 0x0b);
outportb(0x71, regB | 0x40); // enable PIE bit
Enable cascade (IRQ2) and IRQ8 on the 8259:
// enable IRQ0 (timer) IRQ1 (keyboard) and IRQ2 (cascade) on primary PIC
outportb(0x21, ~0x07);
// enable IRQ8 on secondary PIC
outportb(0xA1, ~0x01);
I have read here http://www.compuphase.com/int70.txt that I have to read register C in my ISR so IRQ8 continues triggering...

So I did (in my ISR):

Code: Select all

outportb(0x70, 0x0c);	// select RTC status register C
int val = inportb(0x71);
if(val & 0x40)
{
    ++rtc_ticks;
}
but even so is not working... (bah, working but one shot only)

I tried reenabling the PI bit but that didn't work neither. Do I always need to disable NMI's during reads/writes to ports 0x70/0x71?

Help someone? :?

Posted: Tue Nov 27, 2007 7:02 pm
by Dandee Yuyo
Solved!

Code: Select all

outportb(0xa0, 0x20); // EOI, PIC1
outportb(0x20, 0x20); // EOI, PIC0 
Cannot wait to go 'tickless' now :lol:

Posted: Wed Nov 28, 2007 2:33 am
by JamesM
'tickless'?

Posted: Wed Nov 28, 2007 6:53 am
by Dandee Yuyo
Yes, it's what one of my partners with more experience than me on OSes adviced me:

"...another detail to consider is that nowadays operating systems tend towards the 'tickless' model, that means, no more periodic timer interrupt."

"You program the motorola RTC so it triggers when you know you will do the next context-switch... By doing this you eliminate a lot of overhead, you consume less energy and the laptop batteries last longer."

I'm just wondering how I can mix that with keeping time accurately...

Posted: Wed Nov 28, 2007 10:36 am
by jal
Dandee Yuyo wrote:I'm just wondering how I can mix that with keeping time accurately...
You use the RTC for keeping time. Well, time of day at least. And use some other timer (if there is one) for keeping track of profiling times.


JAL