Sometimes, you will come across task that is literally impossible to get done. You try very hard to finish the task, come up with clever (you think) solutions to work around the problem but all effort fails. Then you take a closer look at the problem and realize it really can’t be done. You can even prove it mathematically no feasible solution can ever exist. You will find yourself really stupid and wish you had spend more time analyzing the problem in the beginning instead of diving into the problem full throttle.
After spending 3 days writing several thousands lines of code that eventually have to throw away, I learn one valuable lesson: never make any attempt to create an accurate interrupt checker. It is impossible to model the exact moment when an interrupt is triggered and when it is cleared by the microprocessor.