Well, I'm a little embarrassed because your suggestion for ANSEL=0 worked! I have two working inputs now. I thought I had tried this but measured the pin and decided it did not work. But it works as an input. One last worry remains. The input on Pin 7 (GPIO.0) still has 1.245 Volts. Vdd is 3.866 Volts. MCLR is pulled up externally with a 5.9K to Vdd. Pin 7 has an external 10K and a switch to GND. Pin 5 (GPIO.2) has the same circuit. Pin 5 measures 3.865V when the switch is not pressed. Both inputs go to zero volts when the switches are pressed. Something is still on at Pin 7 (GPIO.0).
Here is the code that seems to work.
' PIC12F683 SOIC-8 Pin Assignments:
' Pin 1 Vdd +3.8V Power, Battery Voltage +2.5 - 4.5V
' Pin 2 GP5 Out GreenLED Driven by 2N2222, High = LED ON
' Pin 3, GP4 Out RedLED Drivven by 2N2222, High = LED ON
' Pin 4 GP3 N/C
' Pin 5, GP2 In Switch (S1), Low = Pressed
' Pin 6, GP1 N/C
' Pin 7, GP0 In Switch (S2), Low = Pressed
' Pin 8, Vss Supply Ground
'
' Using INTRC Oscillator
INCLUDE "modedefs.bas" ' Mode definitions for Serout
DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _CP_OFF
INTCON = %000001000 'Enable GPIO Change Int but enable interrupts later
OSCCON = %01100000 ' 4mHz
CMCON0 = 7 'Comparators off
ANSEL = %00000000 ; enable digital inputs
TRISIO = %00001111'GP0-GP3 as input
OPTION_REG = %10000000 'Disable Pull ups
'======== SET UP VARIABLES & INITIAL VALUES ====================================
GreenLED VAR GPIO.5 ' Alias Green LED Drive, High = LED ON, Pin 2 Green
RedLED VAR GPIO.4 ' Alias Red LED Drive, High= LED ON, Pin 3 Red
SwitchS1 VAR GPIO.0 ' Alias Switch S2, Low = Pressed, Pin 7
SwitchS2 VAR GPIO.2 ' Alias Switch S1, Low = Pressed, Pin 5
'Pin 4 is set for external MCLR and has a 5.9K pull up
N VAR BYTE ' Counting Variable, used in Auto-OFF Routine
Low GreenLED
Low RedLED
StartLoop:
Pause 10
N=N+1
If SwitchS1 = 0 Then
High GreenLED
ELSE
Low GreenLED
EndIf
PAUSE 10
If SwitchS2 = 0 Then
High RedLED
ELSE
Low RedLED
EndIf
PAUSE 10
GoTo StartLoop ' Repeat
END
Bookmarks