cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 counce

Cl.1
Associate II

Hi guys, i need to ensure there is no swtich bounce for my STM32F4.

Expect use the HAL_Delay is that any way that i able to debounce it?

I will include my code at following:

tenButton_State fnenRead_Pushbutton(void)

{

tenButton_State enButton_State;

enButton_State = HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);

}

void fnvdState_Machine(void)

{

tenButton_State enButton_Read;

tenBoolean boLED_On = FALSE;

volatile tenButton_State enPrevious_Read = NOT_PRESSED;

while(1)

{

enButton_Read = fnenRead_Pushbutton();

if ((enButton_Read == PRESSED) && (enPrevious_Read == NOT_PRESSED))

{

if (boLED_On)

{

  HAL_GPIO_WritePin(LD6_GPIO_Port, LD6_Pin, 0);

  boLED_On = FALSE;

}

else

{

  HAL_GPIO_WritePin(LD6_GPIO_Port, LD6_Pin, 1);

  boLED_On = TRUE;

}

}

enPrevious_Read = enButton_Read;

}

}

0 REPLIES 0