Question
Why variable changes to old value?
I have stm32vldiscovery board. I generated project by stm32cubemx.
I want to switch down led by external interrupt (PA0 button).
I have this in main.c
#include "main.h"
...
uint8_t ldOn = 1;
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
HAL_GPIO_WritePin(LD4_GPIO_Port, LD4_Pin, GPIO_PIN_SET);
while (1)
{
if(ldOn == 0)
HAL_GPIO_WritePin(LD4_GPIO_Port, LD4_Pin, GPIO_PIN_RESET);
}
}stm32f4xx_it.c
#include "main.h"
...
extern uint8_t ldOn;
void EXTI0_IRQHandler(void)
{
ldOn = 0;
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
}When I click on the button, I see in the debugger that the value of the variable changes to 0, and then immediately again to 1.
If I try this code on the stm32f4-disc1 board it works perfectly.
Where I went wrong?