Hello.
First, I want to apologize for taking liberty to correct other people's code. In post no. 31 mr. Roger (flotulopex) accidentaly made a mistake:
Code:
MAIN:
IF PORTA.2 = 0 THEN
<font color="red">PAUSE 300 'debounce</font>
GOTO Program1<font color="red">:</font>
ENDIF
GOTO MAIN<font color="red">:</font>
...
Those colons marked red are surplus and that PAUSE 300 doesn't do any debounce here. It is simply executed immediately after the porta.2 goes low. The most simple way to verify that is to change pause to some larger value, e.g. 1000 (1 sec.) and apply very short (less than 1 sec.) push on button. What will happen is that LED will toggle its state after the pause no matter how shortly you kept the button pressed.
If it was written like this:
Code:
IF PORTA.2 = 0 THEN
PAUSE 300
IF PORTA.2 = 0 THEN Program1
ENDIF
On button-press the program would make a 300ms debounce-pause and then check again if button is still pressed and perceived if it was real button-press or just random noise.
Bookmarks