Help with detachInterrupt() PA4 PA5 behaviour

Post here first, or if you can't find a relevant section!
Post Reply
stefschin
Posts: 4
Joined: Thu Jan 07, 2021 10:02 pm

Help with detachInterrupt() PA4 PA5 behaviour

Post 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
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Help with detachInterrupt() PA4 PA5 behaviour

Post by fpiSTM »

Could you share you code?
stefschin
Posts: 4
Joined: Thu Jan 07, 2021 10:02 pm

Re: Help with detachInterrupt() PA4 PA5 behaviour

Post 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
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Help with detachInterrupt() PA4 PA5 behaviour

Post by fpiSTM »

The full code please.

did you try unitary on those pins ?
stefschin
Posts: 4
Joined: Thu Jan 07, 2021 10:02 pm

Re: Help with detachInterrupt() PA4 PA5 behaviour

Post 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);
}
Post Reply

Return to “General discussion”