8 years, 3 months ago.

Using Nucleo F411RE Analog In as digital ports - InterruptIn problems

Hi

I've a very simple test set-up where I've a potentiometer input at PA_0 (AnalogIn) and five switches at PA_1, PA_4, PB_0, PC_1 and PC_0 respectively, each using InterruptIn.

Not all the InterruptIn ports work correctly (I detect change of state for up and down) - it appears that if I enable / disable combinations I can get the non-functioning part to move around. For example, with all the above configured in my code PA_1 and PB_0 don't respond to their switch action, but if I comment out the code block for PC_0, the switch at PB_0 works.

The code is really simple in that it is the same code snippet repeated but modified for each respective input.

I've also commented out the AnalogIn part in case that was having some effect.

Is this a case of multiple interrupt vector conflict?

Any help appreciated.

Thanks,

Chris

1 Answer

8 years, 3 months ago.

Due to hardware limitations on the nucleo devices you can only attach interrupts on uniquely numbered pins. So for example pb0 and pc0 cannot be used for interrupts at the same time. As long as the number is different, regardless of the port letter, it will work. Just make sure your mbed lib is up to date.

Accepted Answer

Erik - that's a real eye opener and thank you for answering my question. I usually think that I must be blind to a bug in my code but had concluded this wasn't the case! Do you know where this 'feature' is documented as I'm becoming a real fan of Mbed (coming from WinAVR) and am keen to improve my understanding? Chris

posted by Chris Mabey 16 Feb 2016

Sadly with the expansion of mbed to allow new boards, there is no way implemented to really track this for your board. From reading the reference manual in depth you can figure it out, but there is not really a direct way to find it. The older boards have it documented on the InterruptIn Handbook page, and many are more straightforward and can report it via Serial. For example if on the LPC1768 you try to make an interruptin on an unsupported pin, the LEDs start blinking and you get a message on your serial terminal. But with the Nucleo ones it is a bit more complicated for the program to really know if an interruptin is already used.

Although maybe there are options it could be implemented to give an error :).

posted by Erik - 16 Feb 2016