You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's the problem code in WInterrupts.c - note PIOB/C/D handlers have the same problem:
void PIOA_Handler(void) {
uint32_t isr = PIOA->PIO_ISR; // this line should be: uint32_t isr = PIOA->PIO_ISR & PIOA->PIO_IMR;
uint8_t leading_zeros;
while((leading_zeros=__CLZ(isr))<32)
{
uint8_t pin=32-leading_zeros-1;
if(callbacksPioA[pin]) callbacksPioApin;
isr=isr&(~(1<<pin));
}
}
A '1' in PIO_ISR means an edge has been detected on the corresponding pin, regardless of whether the interrupt is enabled by PIO_IMR. If no interrupts are attached, there's obviously no problem as PIOx_Handler doesn't get invoked. As soon as one interrupt is attached, PIOx_Handler will attempt to invoke callbacks for all pins where edges have been detected. I'm guessing callbacksPioA[] is initialised to NULL, so the bug will normally go unnoticed. However, if you attach interrupts to two or more pins on the same port, then use detachInterrupt() to remove one of them, you find that the ISR which should have been detached continues to get invoked!
The text was updated successfully, but these errors were encountered:
Here's the problem code in WInterrupts.c - note PIOB/C/D handlers have the same problem:
void PIOA_Handler(void) {
uint32_t isr = PIOA->PIO_ISR; // this line should be: uint32_t isr = PIOA->PIO_ISR & PIOA->PIO_IMR;
uint8_t leading_zeros;
while((leading_zeros=__CLZ(isr))<32)
{
uint8_t pin=32-leading_zeros-1;
if(callbacksPioA[pin]) callbacksPioApin;
isr=isr&(~(1<<pin));
}
}
A '1' in PIO_ISR means an edge has been detected on the corresponding pin, regardless of whether the interrupt is enabled by PIO_IMR. If no interrupts are attached, there's obviously no problem as PIOx_Handler doesn't get invoked. As soon as one interrupt is attached, PIOx_Handler will attempt to invoke callbacks for all pins where edges have been detected. I'm guessing callbacksPioA[] is initialised to NULL, so the bug will normally go unnoticed. However, if you attach interrupts to two or more pins on the same port, then use detachInterrupt() to remove one of them, you find that the ISR which should have been detached continues to get invoked!
The text was updated successfully, but these errors were encountered: