Products > Embedded Computing

Atmel ATSAMC21 interrupt callback flag not cleared

(1/2) > >>

urosg:
Hi,

I am fairly new to the ATSAM Cortex-M family and have started a new project with Atmel Start where I configured all the needed pins etc. and also set four input pins to have interrupts when a low signal is detected.

So far all good, project compiles, starts and the interrupt callback is called when I press the button (signal to low)

BUT the problem is that the last interrupt callback is then constantly called.

I created a global "count" array for that I increment each time the callback is called, and the counter increases for the last interrupt callback that was called.

What am I doing wrong? Reading ASF4 documentation I do not see any reference that a callback should be "closed" with any specific call to function (i.e. clearing interrupt flag manually).

Any help/reference towards possible solution would be greatly appreciated.

ataradov:
Did you configure it for a falling edge detection, or the low level? If later, then callback will be called for the duration of the button press.

You do need to acknowledge all interrupts. I have no idea if ASF does that for you, you will have to check that yourself.

urosg:
I configured as "low level" but the button is a normal SPDT switch (non-latching) and also the bit in EIC.INTFLAG is cleared, but the callback is still firing - since I am also running FreeRTOS it stops processing tasks as the MCU stays in interrupt routine.

I noticed that the INTFLAG is set to 0x81 and the interrupt routine checks only for the first 4 bits - i.e. when cleared INTFLAG remains at 0x80, which shows interrupt at position 7 as active, but looking through code I could not find anything that would enable this interrupt.

MadScientist:
In the C21 you generally must clear the interrupt flags manually. If you do this too soon you can potentially Re trigger an interrupt when using the EIC

ataradov:
INTFLAG value should not be relevant for the interrupt firing. It is also masked by the value of INTENCLR/INTENSET. But looking at the code generated by start, it actually loops waiting for all flags to clear. And it will get confused by the extra bit set.

Can you share your whole project?

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod