Programming PIT
Posted: Thu May 08, 2014 1:10 am
I an trying to print a message on screen periodically. This is my code from http://www.osdever.net/bkerndev/Docs/pit.htm
unsigned ticks_counter = 0;
Problem #1: But My timer_handler fires only once.
Also I cannot understand meaning of 0x36 (0 011 01 10)
according to http://wiki.osdev.org/Programmable_Inte ... .2FO_Ports
Problem #2:
Its using lowbyte(0 1 = Access mode: lobyte only) only and channel 2 (1 0 = Channel 2)
But its supposed to use channel 0
unsigned ticks_counter = 0;
Code: Select all
void timer_phase(int hz){
int divisor = 1193180 / hz; /* Calculate our divisor */
port_byte_out(0x43, 0x36); /* Set our command byte 0x36 */
port_byte_out(0x40, divisor & 0xFF); /* Set low byte of divisor */
port_byte_out(0x40, divisor >> 8); /* Set high byte of divisor */
}
void timer_handler(struct registers_state *r){
/* Increment our 'tick count' */
ticks_counter++;
/* Every 18 clocks (approximately 1 second), we will
* display a message on the screen */
if (ticks_counter){
char ts_buff[8];
pocha_vga_draws(itoa(ticks_counter, ts_buff), pocha_vga_color(VGA_COLOR_Red, VGA_COLOR_White), 0, 0);
}
}
void timer_install(){
irq_install_handler(0, timer_handler);
}
Also I cannot understand meaning of 0x36 (0 011 01 10)
according to http://wiki.osdev.org/Programmable_Inte ... .2FO_Ports
Problem #2:
Its using lowbyte(0 1 = Access mode: lobyte only) only and channel 2 (1 0 = Channel 2)
But its supposed to use channel 0