Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 3 months ago.
Multiple external interrupts
Hello all,
I am having unexpected behaviour when I try to use several InterruptIn on Nucleo F030R8:
Multiple external interrupts snippet
#include "mbed.h" Serial pc(SERIAL_TX, SERIAL_RX); InterruptIn push1(PF_6); InterruptIn push2(PF_7); InterruptIn push3(PA_13); void pressed1() { pc.printf("1"); } void pressed2() { pc.printf("2"); } void pressed3() { pc.printf("3"); } int main() { push1.mode(PullUp); push1.fall(&pressed1); push2.mode(PullUp); push2.fall(&pressed2); push3.mode(PullUp); push3.fall(&pressed3); for(;;); }
If I only have declared one InterruptIn interrupt, the program works fine, but if I declare more than one, the programs hangs up unexpectedly on interrupt callback.
Reading the uC datasheet, I think that the problem might be that the pins PF_6
, PF_7
and PA_13
share the same interrupt vector.
Does anybody know how to manage this situation? I have tried to use the same function callback for the three interrupts but it does not work.
I am using mbed library Revision 88.
Thank you so much for your help.
Question relating to:
1 Answer
10 years, 3 months ago.
You describe exactly the issue, it only accepts one interrupt per vector. IIRC technically it can quite easily be changed to accept one interrupt per number (eg: those pins you want could work, but for example PF_6 and PB_6 cannot be used at the same time). But then it has to do some decoding, imo it would be nice if that is added, and iirc it is doable, but short term the easier solution for you most likely is to try to use pins with different interrupt vectors.
Hi Erik,
Thank you for your answer.
Could you detail me what I need to change to accept one interrupt per number? I do not mind if I have to decode what pin has caused the interrupt, it is not a critical time task.
Thank you so much again.
Regards!
posted by 12 Sep 2014