12F683 ISR switch debounce

MMcLaren

Joined Feb 14, 2010
861
In the code above (post# 16) the only thing you did was change the #define FT_SWITCH and TRISO and then added the line WPU.0 = 1.
Yes, I did that because I didn't have a resistor handy to throw onto GP3 so I used GP0 and the internal weak pull-up.

How did this (WPU) make it change states as a result of the button press verse follow the push button like it did before?
The button and LED behavior is due to logic in the ISR and main. Changing the switch from GP3 to GP0 and using a weak pull-up on it has nothing to do with the switch logic.

My button circuit has 5v thru a 10K resistor and then thru a 1k to pin 4. My push button in then connected between the junction of the 10K and 1K resistor to ground.

Being that you went back to the original and there is not a WPU for pin 4 how is your switch wired? If there was a WPU setting for a given pin I can see 5V -> resistor -> switch -> pin X but... Going back to the original listing and wiring (post 14)... I added a 10K resistor between GP3 and VDD and with the switch between GP3 and Ground. Same thing you're doing but without the two 1K resistors.

Now I am confused twice because, to me, the WPU acts like a software enabled physical resistor to get rid of floating pins without having to use a physical resistor, but pin 4 (GP3) does not have a WPU enable bit in the WPU register.

Something is just not making sense.
Sorry for the confusion. The snippet RB provided and the listing I provided made a slight change to the switch state logic in the ISR that affects the push button and LED behavior.

I went back to the original (post 14) listing which used GP3 for the switch input after adding a 10K pull-up resistor (see photo below).

Do you need help understanding the switch state logic in the listing I posted or in the snippet RB posted?

Cheerful regards, Mike
 

Attachments

Last edited:

MMcLaren

Joined Feb 14, 2010
861
Dave,

Looking back at your original listing, I don't see why your code isn't working, unless there's a problem reading FT_SWITCH twice, which someone else already mentioned.

I should probably test your original code but it will be awhile before I can do that.

Good luck... Mike
 

Thread Starter

dayv3

Joined May 22, 2014
38
I went back and rechecked everything and after a lot of looking I got
it to work. Thank You to everyone that helped me.

Now... On to the next project.

Dave
 
Top