A problem with __HAL_GPIO_EXTI_CLEAR_IT on Nucleo-F410RB Optimization -03 (stm32cubeide)
Hello,
I have a problem with EXTI0 after a compilation with 03 or Os.
In an ISR (EXTI0 for exemple) the place where the __HAL_GPIO_EXTI_CLEAR_IT is made seems to influence its action. If it is immediately followed by an exit from the ISR it does not work. Here is an example below
--
This is the ISR (on a Nucleo-F410RB compilation -03):
void EXTI0_IRQHandler(void)
{
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
GPIOA->BSRR = GPIO_PIN_6;
GPIOA->BSRR = GPIO_PIN_6<<16u;
}//OK 1 pulse
When i have un pulse on Line 0, I have one pulse on PA6.
(the code is intentionally minimalist, use __HAL_GPIO_EXTI_GET_IT does not change the behavior)
But if I change the code to :
void EXTI0_IRQHandler(void)
{
GPIOA->BSRR = GPIO_PIN_6;
GPIOA->BSRR = GPIO_PIN_6<<16u;
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
} // NOT OK 2 pulses !
I have 2 pulses on PA6. It’s like the flag was not yet reset to 0.
And when I try :
void EXTI0_IRQHandler(void)
{
GPIOA->BSRR = GPIO_PIN_6;
GPIOA->BSRR = GPIO_PIN_6<<16u;
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
__NOP();
} //OK
Or
void EXTI0_IRQHandler(void)
{
GPIOA->BSRR= GPIO_PIN_6;
GPIOA->BSRR= GPIO_PIN_6<<16u;
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
__ISB();
} //OK
All is correct, just one pulse on PA6.
Of course, in O0 everything is ok but in O3 or Os I have this problem on this board.
Just for information, on a nucleo-F030R8 with the same code and same optimization (Os or O3), All is correct, just one pulse on PA6.
void EXTI0_1_IRQHandler(void)
{
GPIOA->BSRR= GPIO_PIN_6;
GPIOA->BSRR= GPIO_PIN_6<<16u;
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
} //OK 1 pulse on PA6 !!!
why (on the F410RB) is it necessary to have at least one tick between the flag reset and the exit of the ISR?
Does anyone have a explanation to help me understand?
thank you in advance
