Page 1 of 1

Help with detachInterrupt() PA4 PA5 behaviour

Posted: Thu Jan 07, 2021 10:32 pm
by stefschin
Hi,
I'm working with STM32 BluePill in a like PLC board, and I use 6 GPIOs as user Inputs.
4 are tact switches for menu navigation conected to PA6, PA7, PB10, PB11
2 are for Start and Stop commands in PA4 and PA5.
I use TMR2 INT every 1 ms to make various functions and one of them are debounce for switches.
I use PlatformIO with Arduino framework, with last 11 platform that uses stm32duino 1.9.0
In some parts of menu, I attach and detach EXT INT for just check or Menu switches and/or Start, or Stop
For menu switches is working well, but with Start and Stop it doesn't work detachInterrupt(pin).
I see in other theard that it has to use after calling this function:

Code: Select all

  __DSB();
  __ISB();
I've tried different setups and functions but without succes. Just randomly a few times it works .
Any help? maybe it's an Arduino core bug or maybe I'm making something wrong.
I read microcontroller Reference Manual but didn't find anything special about this GPIO's
Thanks

Re: Help with detachInterrupt() PA4 PA5 behaviour

Posted: Fri Jan 08, 2021 9:08 am
by fpiSTM
Could you share you code?

Re: Help with detachInterrupt() PA4 PA5 behaviour

Posted: Thu Jan 14, 2021 6:28 pm
by stefschin
Sorry I didn't get notify by email and notificactions.

I send my code of attaching and detacching interrupt
// Función de pulsadores des/habilitadas
void pulsa_st_on()
{
attachInterrupt(START_B,ST_EXTI_ISR,FALLING);
}
void pulsa_st_off()
{
detachInterrupt(START_B);
}
I try to add:
__DSB();
__ISB();
but it doesn't change his behaviour

Re: Help with detachInterrupt() PA4 PA5 behaviour

Posted: Thu Jan 14, 2021 6:55 pm
by fpiSTM
The full code please.

did you try unitary on those pins ?

Re: Help with detachInterrupt() PA4 PA5 behaviour

Posted: Fri Jan 15, 2021 7:19 pm
by stefschin
fpiSTM wrote: Thu Jan 14, 2021 6:55 pm The full code please.

did you try unitary on those pins ?
My code has more thank 3k lines! I think you want my pinout setup:
pinMode(OK_B, INPUT_PULLUP);
pinMode(UP_B, INPUT_PULLUP);
pinMode(DOWN_B, INPUT_PULLUP);
pinMode(CANCEL_B, INPUT_PULLUP);
pinMode(START_B, INPUT_PULLUP);
pinMode(STOP_B, INPUT_PULLUP);

//Initialize Timers**************************************************
Timer2->setOverflow(1000, MICROSEC_FORMAT); // 1000 microseconds = 1 milliseconds

//Initialize Interrupts**********************************************
Timer2->attachInterrupt(TMR2_ISR);
Timer2->resume();


then I call this functions in some parts of my program
// Función de pulsadores des/habilitadas
void pulsa_st_on()
{
attachInterrupt(START_B,ST_EXTI_ISR,FALLING);
}
void pulsa_st_off()
{
detachInterrupt(START_B);
}