Suggested addition to Bran's Known Bugs

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
rknox
Member
Member
Posts: 55
Joined: Wed Apr 28, 2010 9:07 am

Suggested addition to Bran's Known Bugs

Post by rknox »

I understand the tutorial is located elsewhere, but it is referenced here and there is a Known Bugs page here.

In Bran's discussion of the Programmable Interval Timer, there is the following function. I have aded the comment and the first line of code.

Code: Select all


void timer_phase(int hz)
{
/*
 * The low order 16 bits of divisor is sent to the PIT to load a 16 bit countdown timer.
 * Any value of hz that results in divisor being greater than 64k will produce erratic
 * results because only the low 16 bits of the resulting divisor will be used.
 * The smallest value of hz acceptable is thus 19. 
 * The bios usually will set the countdown register at the largest possible value
 * 64k-1, resulting in an interrupt frequency of 18.2065 Hz.
 * see http://wiki.osdev.org/Programmable_interval_timer
*/
    if (hz < 19) hz = 19;                /* see comment above */
    int divisor = 1193180 / hz;       /* Calculate our divisor */
    outportb(0x43, 0x36);             /* Set our command byte 0x36 */
    outportb(0x40, divisor & 0xFF);   /* Set low byte of divisor */
    outportb(0x40, divisor >> 8);     /* Set high byte of divisor */
}
Post Reply