I am using a counter to measure the on and off time of the led input given to a GPIO pin. There is a LED On ISR and LED Off ISR. I read the counter value at the start of each ISR and set a flag. This flag is polled in the infinite FOR loop in the main.
When my code runs, it sometimes enters LED On ISR twice consecutively and gives weird on time values. I have logic for resetting the counter in my ISR using the control register.
What could be the reason?