If you look ta Keil ap note you will see -
1) First thing done in ISR function is turn off interrupt, ET0, next execute
ISR code, then turn interrupt back on.
2) In main() use one instruction to enable ISR and do it right after main() and before
your while() loop. For both EA and ET0. The only time they will be turned off and back on
after this initialization is in ISR, just ET0. In ap note is an initialization routine that only needs to
be called once.
3) As I discussed before you need to declare variables in ISR as volatile. Look at this
discussion of static and volatile variables as applied to ISR.
What's the difference between using the variable specifiers static volatile combined? Or using one alone; like static or volatile in microcontroller programming?
4) Where is definition of variables answerIsWrong and answerIsRight ?
Some examples -
8051 microcontrollers have two timers/counters, which can be used as either timer to generate delay or counter to count external events.
Note some of the examples do not declare ISR variables as volatile, that is
a mistake. Always declare ISR variables as volatile.
In you debugger can you see you are getting into ISR routine ?
Lastly your test for timer value, example "if(aux2==40){"
In your example code this is OK because you have no other ISR
activity. However if you did you would change this to
"if(aux2 >= 40){" because you could miss a timer value while
another ISR is executing. Or do the "==" test in the ISR and set
a flag, process the flag in main(). Whether or not this is a problem
also depends on priority assigned to ISRs.
Regards, Dana.