Use interrupts in RAK5205

Hi,
I customize the firmware (make the changes under based on RAK811\app_5205) and add interrupt handling-
the init code-
Int_1.pin_num = PB3; //pin 15
Int_1.dir = RUI_GPIO_PIN_DIR_INPUT;
Int_1.pull = RUI_GPIO_PIN_PULLUP;
rui_gpio_interrupt(true, Int_1, RUI_GPIO_EDGE_FALL, RUI_GPIO_IRQ_HIGH_PRIORITY, counter_int);
The int routine -
void counter_int()
{
counter++;
}

When adding printing I see that the routine called continuasly.
What is wrong here?
Thanks

Hi,@sagis

pin_num is pin number of the RAK811 module, not PB3. If you want to set PB3,you must set it like this Int_1.pin_num = 15;

Of corse. Not put here all my changes but the definition of PB3 appears earlier in my code:
#define PB3 15
The interrupt routine called many times so the pin definition is correct. Maybe the problem with the pull-up resistor? Could you try this small piece of code on your HW?
Thanks

Hi @sagis
This is related to the external circuit, you’d better use an oscilloscope to measure the waveform of the pin

Checked the voltage on the PB3 (the pin with the pullup) and it is 0.
When trying to work with pulldown, only when the scope is connected the interrupt received.

This has a lot to do with external circuits,I can’t understand your problem.
Can you show me the external circuit diagram of this pin?

something simple… switch which have to count the time that the circuit closed -
image

Thanks!

@sagis
It’s a high impedance state default.Give this pin a pull up with a resistor to VCC ,then configure it as RUI_GPIO_EDGE_FALL and try it again.

Hi @leopold,
I can’t add resistor to each board… what solution would you recommend for counter implementation?
Thanks

@sagis
Can you use RUI online compiler?

Yes, I’m using the RUI

Hi @sagis
I just modified the SDK about PIN_PULL parameter,you can use the following initialization and try again.
Int_1.pin_num = 15;
Int_1.dir = RUI_GPIO_PIN_DIR_INPUT;
Int_1.pull = RUI_GPIO_PIN_PULLUP;
rui_gpio_interrupt(true, Int_1, RUI_GPIO_EDGE_FALL, RUI_GPIO_IRQ_HIGH_PRIORITY, counter_int);
After initialization, first measure whether the pin is high level.

Hi @leopold, Pin 15 not in high level after the initialization.
is it possible to check the SDK version (maybe cache issue…)

Hi @sagis,Can you use following RUI online compiler?

yes. http://47.112.137.11:12090/#/

Hi @sagis
Sorry, I don’t have a RAK5205 module at home now. Could you please send me your test_app.c and I will directly modify it locally? After that, I will send you an email with the firmware.Or have to wait for a few days will go to work normally. We will update the SDK after local testing in your way.
my email:[email protected]

Hi @leopold, Sent.
Thanks

Hi @sagis ,
Sorry for so late.you try to recompile and try again now.

Work OK now!
Thanks @leopold it is very helpful

Well,thanks for your support of RAK products. :smiley: :smiley: