Hi,
eddyb wrote:until i enter the loop, it is executed about 100 - 1000 times per second
Do you know this, or are you assuming this?
Perhaps it's operating at 100 to 1000 times per second for a total of 0.01 to 0.001 seconds before your loop starts (and only firing once)...
In general, the CPU doesn't know the difference between "straight" code and a loop.
As I mentioned earlier there are problems with 2 CPUs, but in both of these cases the problem involves instructions that lock the bus (an explicit "LOCK" instruction prefix and/or an "XCHG" instruction that implicitly locks the bus). One is relatively rare/old Cyrix chips that you're not using, and one involves Pentium 4 with hyper-threading (and I really don't believe your OS is capable of using hyperthreading). Secondly, your loop doesn't do anything that locks the bus anyway. Therefore buggy CPUs are not the problem, therefore there isn't any difference between "straight" code and a loop, therefore your code or your compiler is buggy.
I *severely* doubt the compiler is buggy. I don't even need to know which compiler you're using to say this, because no compiler has ever been so buggy that it'd mess up such a simple loop (and I doubt any compiler ever will be that buggy).
That leaves your code and nothing else.
The loop itself has nothing to do with the problem. IMHO it only looks like the loop causes the problem because the code before the loop is too short for you to notice if the IRQ fires or not.
Cheers,
Brendan