Adam
Adam

Reputation: 735

Counter vs Timer in C - PIC MCU

I’m sure it’s best practice to use a timer for let’s say button debouncing logic.

But I have some simple code that just counts inside the main while loop.

Are there any big disadvantages to doing that?

Upvotes: 0

Views: 79

Answers (1)

legden
legden

Reputation: 73

I think it is quite OK to make bounce protection based on a counting variable in a simple application. The main disadvantage of this it's a difficulty of preserving the timing characteristics of the debouncing if the application needs to be grown in the future. Also you can't implement powersaving logic while waiting for timer interrupts.

Upvotes: 0

Related Questions