2022-11-01 06:47 AM
I am implementing an application when I need to set high a status variable when a button is pressed. I would like to do so via the interrupt routine of the push button. So, in gpio.c I have
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
if (GPIO_Pin == GPIO_PIN_0){
PB1_isPressed = 1;
}
}
In the main.c I would like to have a statement like:
if (PB1_isPressed ==1){
do something
}
Now my questions are the following:
Sorry for the very basic questions and thank you all for the help in advance :)
Solved! Go to Solution.
2022-11-03 01:34 AM
Yes, I agree
the variable might be modified by the interrupt service routine so it must be declared as volatile
thank you for your comment
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.