I have a weird problem with my code. It is somewhat hard to explain
without seeing the code first, so Ill post the code first.
I am implimenting an routines for a system timer in my OS using
the 8253/8254 PIT. I wrote code to test the timer:
Code: Select all
Sys_gotoxy (0,24);
Sys_settextcolor (COL_BLUE,COL_WHITE);
Sys_puts ("MicroOS Operating System Starting up... ");
while (1) {
Sys_gotoxy (0,20);
Sys_puts ("PIT Test uses sine wave to generate pulses. This text should blink.");
Sys_Timer_Wait (500);
Sys_gotoxy (0,20);
Sys_puts (" ");
Sys_Timer_Wait (500);
}
![Wink ;)](./images/smilies/icon_wink.gif)
This code is supposed to blink (using my timers wait() routine)
the text "PIT Test..etc". Note that it is in an infinity loop.
Here is Sys_Timer_Wait():
Code: Select all
volatile long int _Sys_TickCount = 0;
//etc...
void Sys_Timer_Wait (int ticks) {
unsigned long ulTicks;
ulTicks = _Sys_TickCount + ticks;
while (_Sys_TickCount < ulTicks)
;
// _Sys_TickCount is updated by interrupt,
// so we dont need to update here
}
the global system counter (_Sys_TickCount)
Now for the problem...
-> It works fine in the Bochs emulator (only the "PIT test" string blinks,
as it should)
-> On 3 laptops, *both* strings (the one in the infinity loop, the "PIT test"
string, *And* the string *outside* the infinity loop ("MicroOS is starting")
blink.
Why would the string outside the loop blink as well..?
Also, every 28 blinks, the "PIT test" string (The one that should
blink) dissapears. 28 blinks later (The "MicroOS is starting" string
still blinks, as it shouldnt), the "PIT test" reappears.
What could cause this?
-> On PCs (I only tested 1 here), it causes a GPF.
I suspect the GPF and the odd string problems with laptops are somehow
related. (It works in Bochs though)
By "blink", I mean the text dissapears, and then reappears (Only those
two strings. No other string output is effected by the timer)
The blinks are consistant, so I know the interrupt is getting executed
at constent intervals.
Im not sure what could cause these problems, and am looking for any
possible suggestions here.
I am using NASM and GCC.
Thanks for any suggestions!