Page 1 of 1

sleep function.. please help

Posted: Wed Jun 04, 2003 8:28 am
by Wacky
Hello, i need a sleep funktion like sleep(5000), so that my OS sleep 5 seconds. I have a PIT and a init_timer function (see below).

Now, how can i realize a sleep function?? I have no idea and not found any examples or good informations about this in the forum and google. :'(

please help.. thx Wacky

My PIT:

Code: Select all

#define PIC1 0x20
#define PIC2 0xA0

#define ICW1 0x11
#define ICW4 0x01

#define PIT_CTRL 0x43
#define PIT_CH_0 0x40

void init_pics(int pic1, int pic2)
{
   outportb(PIC1, ICW1);
   outportb(PIC2, ICW1);

   outportb(PIC1 + 1, pic1);
   outportb(PIC2 + 1, pic2);

   outportb(PIC1 + 1, 4);
   outportb(PIC2 + 1, 2);

   outportb(PIC1 + 1, ICW4);
   outportb(PIC2 + 1, ICW4);

   outportb(PIC1 + 1, 0xFF);
}
My init_timer:

Code: Select all

init_timer(unsigned char FREQ)
{
   unsigned int counter=1193181/FREQ;
   outportb(PIT_CTRL, 0x34);
   outportb(PIT_CH_0, counter%256);
   outportb(PIT_CH_0, counter/256);
}
In my main-function i'm calling:

Code: Select all

init_pics(0x20, 0x28);
init_timer(100);

Re:sleep function.. please help

Posted: Wed Jun 04, 2003 8:49 am
by Pype.Clicker
http://www.mega-tokyo.com/forum/index.p ... 36;start=0

this thread should have all the information you need (and perhaps a bit more)

if you still need advices after this, just ask :p

Re:sleep function.. please help

Posted: Thu Jun 05, 2003 11:50 am
by Wacky
OK, i've toyed a little bit with the functions you've postet in the threat above, but anyway i've no idea!!

if i set the timer at 100 (init_timer(100)), the IRQ0 fires 100 times per second, right?
Now i have to count every fire of the IRQ0, but how can i notice if the IRQ0 fires??

thx.. Wacky

Re:sleep function.. please help

Posted: Thu Jun 05, 2003 12:10 pm
by Pype.Clicker
hum, maybe just because the interrupt handler gets called ?