sleep function.. please help

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
Wacky

sleep function.. please help

Post 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);
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:sleep function.. please help

Post 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
Wacky

Re:sleep function.. please help

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:sleep function.. please help

Post by Pype.Clicker »

hum, maybe just because the interrupt handler gets called ?
Post Reply