After a software reset, I reactivate the interrupts. however, if the pin is high it gives me an unwanted first interrupt.
I tried deatach first maybe there should be a way to reset the flag.
In general - Read the forum guidelines to see how to properly ask a question and some good information on making a good post. You will get faster and better help if you post all your code as requested by the forum guidelines.
Because it only happens in some cases, it depends on the voltage on the encoder phases.
I solved it by saving the quota before enabling the interrupt and retrieving it afterwards.
But it is not an elegant solution.
Personally, I wouldn't use the Arduino Low Power library for interrupt handling.
For some reason the library unnecessarily clocks the SAMD21 External Interrupt Controller (EIC) with the ultra low power 32.768kHz oscillator (OSCULP32K) during deep sleep. I can only imagine this is so that it can wake up the CPU using edge triggered interrupts.
However, the EIC doesn't need to be clocked during sleep, since the CPU can be woken up with asynchronous, level interrupts anyway. Furthermore, the standard SAMD21 attachInterrupt() function provides wake up functionality by default anyway.
The next issue is that there's no corresponding LowPower.detachInterruptWakeup() function. This means that once the CPU has woken up, the EIC continues to be clocked by the slow 32.768kHz OSCULP32K oscillator, rather than the 48MHz digital frequency locked loop (DFLL48M) as it would normally.
The result is that that this massively increases the interrupt signal latency. This is could be an issue, for example if the microcontroller were to subsequently be interrupted by fast input signals.
It's all working, but I still want to see if there's a better solution.
I have to count a slow encoder, when running on batteries, handle TFTs and a thousand other things when powered at 12V.
I have three interrupts, two for the encoder phases, and one for the 12V going away.
You say it wakes up from LowPower.deepSleep(); even without LowPower.attachInterruptWakeup ?