Hi,
I have a Push Button with pullup connected to digital in pin. I'm reading from digital Pin having attached an IRQ routing with
attachInterrupt(digitalPinToInterrupt(pin), IRQ_ForPin, CHANGE)
In the Interrupt routing I read the value of the pin
value = DigitalReal(pin)
My problem is, that sometimes the value read is not the value of the pin.
Looking at the IRQ handling shows, that IRQ routing is called before interrupt is cleared. So pin may change after I read and before IRQ is cleared. Thats seems to be my problem. This can be fixed, by clearing IRQ after call attached function.
After doing this change, this issue is gone:
From WInterrupts.c:
void EIC_Handler(void)
{
[...]
{
if ((EIC->INTFLAG.reg & ISRlist*) != 0)*
- {*
- // interted here*
- // Clear the interrupt*
_ EIC->INTFLAG.reg = ISRlist*;_
_ // Call the callback function*_
_ ISRcallback*();
// commented out here*
* // Clear the interrupt*
// EIC->INTFLAG.reg = ISRlist*;
}
}
}*
I assume, that a bug. How can I get this fix into the official version Arduino for MKRZero?
Thanks and best regards
Achim_