I need two interrupt pins on a Nucleo-L432KC project (I’m using PwmInRc). The interrupt works when using PA_3, but i’ve tried other pins without success. It doesnt seem to matter if I only use one pin vs. two.
I’ve tested mbed 2 r 172:65be27845400 as well as mbed-os 6691:cf4f12a
I’ve done a fair amount of searching and see that interupts wont work across the same pin number on different ports (so PA_3 and PB_3 wont work). However I’ve tried for instance PA_3 and PB_6 and that doest seem to work. The datasheet seems to say there are 16 interrupt channels on the L432KC.
Using STM32CubeMX i can confirm that PA_1 is assigned to EXTI_1 and PA_6 is assigned to EXTI_6. I’ve been looking thru the InterruptIn.cpp and InterruptIn.h but unfortunately I’m not making headway.
This is the test code I’ve been using. I’ll go back and test this on a breadboard again because i’m paranoid about silly mistakes. I’ve tried various things like external discrete pull-ups as well.
#include "mbed.h"
#include "PwmIn.h"
PwmIn RC1_IN(PA_1);
PwmIn RC2_IN(PA_6);
DigitalOut MYLED(LED1);
int main() {
while(1) {
MYLED = 1;
wait(.50); // 500 ms
MYLED = 0;
printf("pw %f us ",RC1_IN.pulsewidth());
printf("pw %f us \r",RC2_IN.pulsewidth());
wait(.50); // 500 sec
}
}
So after more digging, my problem appears to be hardware. On a breadboard, with no external passives (no pullups) i’m able to get the test code to work properly with PA_3 and PA_6.
Hmm…why didn’t you declare the inputs as interrupts and use them as such? I have not tried to use the PWMIn declaration as you did so I can’t comment on it.
The problem was actually and entire bag of bad RC three wire jumpers. On average one of the three cables was bad, causing strange and confusing behavior.