RAK811 Disable digital input interrupt

Hi
I set up an interrupt driven by a digital input pin connected to a pushbutton, (the digital pin have external pull up resistor because RUI isn’t activating the internal ones! ) the interrupt works fine and wakes the module as expected, however, i want once the interrupt fired, disable it, do some tasks and just before going to sleep enable it again.

In some forum topic i read about to un-initialize the digital pin to stop interrupt, however isn’t working. tried to put the gpio un-init code inside interrupt handler, inside bsp_wakeup(), or even in the main loop and none seems to work, because the interrupt keeps kicking if the switch is pushed.

Does somebody faced the same problem and have a working piece of code to disable digital input pin interrupt?

Thanks in advance

some portions of the code:

//DIO init code:
Switch_One.pin_num = SWITCH_1;
Switch_One.dir = RUI_GPIO_PIN_DIR_INPUT;
Switch_One.pull = RUI_GPIO_PIN_PULLUP; // using external pull up because here isnt working rui_gpio_interrupt(true,Switch_One,RUI_GPIO_EDGE_FALL_RAISE,RUI_GPIO_IRQ_LOW_PRIORITY,handle_int_sw1);

//INT handler
void handle_int_sw1(void)
{
RUI_LOG_PRINTF(“sw1 int fired! \r\n”); //msg printed so INT is working ok!
rui_gpio_uninit(&Switch_One); // Disabling int not working here!
dig_flag = true;
}

void bsp_wakeup(void)
{
/*****************************************************************************
* user process code after exit sleep
******************************************************************************/
rui_gpio_uninit(&Switch_One);
RUI_LOG_PRINTF(“uninit sw1 int \r\n”); // tried to disable here too but, still kicking
}

Dear alnunez,
You are doing a great job, but unfortunately: the interface for external interrupts can only be opened, not closed, which will have to affect your work.

Have a volatile flag that you can set - so whilst you are processing your interrupt, the flag is set such that any further interrupts are silently dropped - when you have finished, reset the flag so the interrupt processing code is re-enabled.

Hum, well, tried the flag option, but sometimes when pressing a button, the microcontroller gets stuck and needs to be rebooted.

The code is based on the simple RAK811 RUI example, just adding digital input push buttons, pull up resistors, and interupts to wake the module when some button is pressed, and transmit via LoRa

I traced the problem wit lot of printfs, and found the code executes ok until this line of code:

.
.
rui_return_status = rui_lora_send(8,a,sensor_data_cnt);
switch(rui_return_status)
.
.

My best guess is, if the digital input interrupt is fired in the middle of rui_lora_send() call something bad happens.I don’t know exactly if the program counter is jumping somewhere …

So that’s the reason why asked how to turn off digital inputs interupts once fired!

I’m writting a very simple, but common application: digital sensor closes - module wakes up - digital input interupts turned off - status sent via lora- digital interrupts turn on again - module sleep

And because the “noisy” nature of the digital sensors used : push buttons, float switches, reed relays, etc. There’s now way to guarantee there not will be interruptions in the middle of the lora send process, so again thats why i want to turn off digital pin interrupts in the middle of the lora send process.

If somebody faced the same problem (and solved it) please tell me how!

Thanks in advance

If you’ve turned the "don’t process’ flag on on the first button press and the button press is to do a LoRa send, only reset it after the send has completed.

I tried that, but it doesn’t avoid the ISR called in the middle of the lora_send function. It’s not a reliable solution. I think the ISR of the pushbutton is messing with the interrupts used by the lora_send function to comunicate to the semtech chip. Probably the IRQ is shared, and the RUI handler wasn’t carrefully crafted to allow external pin interrupts different that their own in some specific moments.
Here is the code i’m testing https://github.com/galopago/RAK811_RUI_SWITCH_SENSOR
Thanks in advance

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.