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.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.
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.How did this (WPU) make it change states as a result of the button press verse follow the push button like it did before?
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.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.
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
-
38.3 KB Views: 14
Last edited: