Hi all,
I'm sure everybody here has at some stage dealt with switch debounce...
I tried my first switch (membrane) a while back with method 1, using a pull-up (10k) across switch and +5V and other switch side to RB4
now I want to use portB weak internal pull-ups and pull down ( 10k) to gnd on other microswitch side, method 2.
I understand the concept of switch debounce and have writen code (MICROCHIP .asm) that would use a set count value to debounce the switch, not working.
So I would put it to all those with experience out there, is there anything a newbie might not have considered when doing this simplest of functions.
natbit[/img]
I'm sure everybody here has at some stage dealt with switch debounce...
I tried my first switch (membrane) a while back with method 1, using a pull-up (10k) across switch and +5V and other switch side to RB4
now I want to use portB weak internal pull-ups and pull down ( 10k) to gnd on other microswitch side, method 2.
I understand the concept of switch debounce and have writen code (MICROCHIP .asm) that would use a set count value to debounce the switch, not working.
Code:
SW1:
movlw b'01111111'
movwf PORTB
;PAGE1
;bsf TRISB, 7
;bcf OPTION_REG, 7
;PAGE0
btfss PORTB, 7
goto endswitch
incf SW1count
movf SW1count, 0
xorlw DEB_VAL
btfss STATUS, Z
goto endswitch
clrf SW1count
bcf STATUS, Z
movf DISP_Num, 0
xorlw d'9'
btfss STATUS, Z
goto $+3
clrf DISP_Num
goto $+1
incf DISP_Num
return
endswitch:
PAGE1
clrf TRISB
PAGE0
return
So I would put it to all those with experience out there, is there anything a newbie might not have considered when doing this simplest of functions.
natbit[/img]