AnsweredAssumed Answered

Why is priority HAL_DELAY  compared to button?

Question asked by Lex Trc on Jul 20, 2017
Latest reply on Jul 21, 2017 by Clive One

Hi,


i've a little problem with stm32L0.
I want change state with button B1, but HAL_DELAY is priority of button.
the mian is:
uint8_t stato;
stato = 0;

while (1)
{

switch(stato)
{
case 0:
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
HAL_Delay(500);
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
HAL_Delay(500);
if(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)==GPIO_PIN_RESET)
{
stato = 1;
}
break;
case 1:
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
HAL_Delay(100);
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
HAL_Delay(100);
if(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)==GPIO_PIN_RESET)
{
stato = 0;
}
break;

}

}

Outcomes