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, 7 months ago.
Nucleo 401 Multiple InterruptIn Pins
I have tried to use InterruptIn on two different pins (PA_6 & PA_7), but it does not appear to be working. If I only declare either one or the other pin using InterruptIn, then the corresponding Interrupt Service Routine (ISR) works exactly as expected. I have not delved into the source code, but maybe more than one pin is not yet supported? If not, then does anyone know when more than one pin might be supported or if there is a work-around?
InterruptIn leftEncoderClk(PA_6);
InterruptIn rightEncoderClk(PA_7);
int leftEncoderTicks = 0;
int rightEncoderTicks = 0;
void leftEncoderTick() { leftEncoderTicks++; }
void rightEncoderTick() { rightEncoderTicks++; }
int main() {
leftEncoderClk.mode(PullDown);
rightEncoderClk.mode(PullUp);
leftEncoderClk.rise(&leftEncoderTick);
rightEncoderClk.fall(&rightEncoderTick);
}
Regards, Abe
Question relating to:
2 Answers
10 years, 7 months ago.
I think this is because EXTI5 to EXTI9 are sharing the same interrupt vector. this means all port pins with number from 5 to 9 will trigger the same interrupt routine (PA_6, PA_7, PB_8...)
regards, MaxT
Maxime, thanks for the information. Now the resulting behavior makes some sense. I just downloaded the reference and programming manual for the STM32401RE, so I should be able to take a closer look. I am hoping that there is a flag or some way for me to identify which pin triggered the corresponding interrupt. Then I can simply have one ISR that checks for a PA_6 or PA_7 trigger event.
Regards, Abe
posted by 12 May 201410 years, 7 months ago.
I don't have it myself, so cannot test it, but is your mbed library up to date? Afaik that should be possible with the newer mbed libs (you just cannot have several interrupts on the same pin number, so not PA_6 and PB_6, hardware limitation.
Click on your mbed lib in the compiler, check if there is an update button at the right side.
I have the latest mbed library, but the interrupts do not function as expected. If I only use one or the other, then the active interrupt functions properly. When I activate both interrupts, then only the PA_7 interrupt is triggered, but it is triggered far more times than it should and it appears that a transition on PA_6 induces the additional triggering.
I don't understand the PA_6 & PB_6 limitation as PB_6 is D10 & PA_6 is D12?
Regards, Abe
posted by 11 May 2014Just tried removing PA_6 and used PA_7 & PB_8, but the same behavior persists when two InterruptIns are implemented.
Regards, Abe
posted by 11 May 2014