Page 1 of 1

8253 PIT timer problem

Posted: Mon May 19, 2003 11:52 pm
by mr. xsism
hello fellow devers,
i seem to be having a problem with getting my PIT ISR to be called. Remapped the PICs to 0x20 and installed the PIT ISR to 0x20(IRQ0), but it never gets called. Actually, in bochs, when you reset it gets called once, but not on a PC. Here is the PIT init code:

Code: Select all

extern void timer_ISR();
dword ticks;
char tstr[9];

void mud()
{
   /* mud delay */
   if(10 > 9){   if(10 / 2 > 5){}}
}

void timer()
{
   ticks++;
   
   itoa(ticks, 10, tstr);

   print("ticks:",0,10,0x04);
   print(tstr,0,11,0x04);
   
   outportb(0x20, EOI);
}

void pit_init()
{
   disable_ints();
   outportb(MODECTRL, S_CNTR0|RWLSB_MSB|MODE3);
   //mud();
   outportb(COUNTER0, LOBYTE(0));
   //mud();
   outportb(COUNTER0, HIBYTE(0));
   
   AddInt(0x20,timer_ISR,G_INT|G_PRESENT|G_DPL0|G_32BIT, 0x8);
   unmaskIRQ(TIMER);

   ticks=0;
}
[\code]

I have tried different modes, frequencies and even interrupts, but no luck. I know the ISR is there because i can call it with the asm int command. Please help me out, i really need this done. thank you in advance.

Regards,
mr. xsism

Re:8253 PIT timer problem

Posted: Tue May 20, 2003 1:54 am
by Pype.Clicker
i would say that either your unmasking isn't correct, or your IF flag is still cleared.
btw, i'm not sure to like very much the way you reprogram the PIT itself ... why do you need to put it in "count to zero "mode ... and if you set the counter to zero, aren't you disabling its counting ?

Re:8253 PIT timer problem

Posted: Wed May 21, 2003 12:16 am
by mr. xsism
doesn't matter anymore, i got it working. The problem wasthat the kernel was ending and at the end i have it "cli" and "hlt" therefore nothing can happen, including the timer being called.

About the zero thing, I'll kindly tell you that you are wrong, eventhough you mercilessly bashed me in my other post about the IDTkernel. With the PIT counter, 0 = 65,***. It is the standard value(18.2 ticks/second). 1 is actually the lowest count.

Here's to good sportsmanship :P

Regards,
mr. xsism

Re:8253 PIT timer problem

Posted: Wed May 21, 2003 2:22 am
by Pype.Clicker
hehe... taking a revenche, hey :D

well, i looked at the 8253 a l000t of years ago, and i must admit that i usually just leave it as the BIOS configured it and only change its frequency with

Code: Select all

  outb(0x36,0x43);
  outb(1193%256,0x40);
  outb(1193/256,0x40);
-- hum, maybe it's the same once symbols are resolved (i know, i deserve dead for using outb(value, port) rather than (port,value))
Maybe the fact i use 0xFFFF instead of 0x0000 is the reason why i experience clock drifts when i return to DOS after Clicker exitted ...