Thank you Ioannis!
A funny thing happened to me on the way to re-turning to this....... This morning it worked as I would have expected.
And I couldn't reproduce the previous behavior.
But I do thank you for prompting me.
I would have otherwise thought wrong about the chip.
Here is the code and use case:
I have a re-built Nintendo game controller.
It originally had a 4021 shift-register which died.
So I removed that part and replaced it with 6 germanium diodes - which convert 6 possible button presses to a 3-bit binary word (0-7)
For my test bench I have a pic-based LCD display I use as a Serial Monitor
' Name : 12F683_DiodeSwitchControl_SerialLCD-DisableMCLR.pbp
' Compiler : PBP3
' Target PIC : PIC12F683
' Oscillator : 4MHz internal
' Description : Diode Switch matrix 6 switches to 3bit binary
' Note: Disable MCLR_reset function PIN-4 to use this pin as input
' Send Output to Serial LCD
'1 VDD
'2 GP5/T1CKI/OSC1/CLKIN
'3 GP4/AN3/T1G/OSC2/CLKOUT
'4 GP3/MCLR/VPP
'5 GP2/AN2/T0CKI/INT/COUT/CCP1
'6 GP1/AN1/CIN-/VREF/ICSPCLK
'7 GP0/AN0/CIN+/ICSPDAT/ULPWU
'8 VSS
#CONFIG
__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
#ENDCONFIG
Include "modedefs.bas" ' Mode definitions for Serout
' Alias pins
LCD Con 0 ' Alias GPIO.0 to Serial LCD
' INIT global variables
SwitchNum Var Word
' Function Registers Setup
ANSEL = 0 ' Disable analog A/D functions
CMCON0 = 7 ' Analog comparators off
TRISIO = %00001110 ' GPIO.1,2,3 inputs - others outputs - and GP0 feeds LCD
GPIO = 0 ' Flush GPIO
' MAIN PROGRAM
mainloop:
Serout LCD, T9600, ["?c0"] ' Turn off flashing cursor
pause 50
Serout LCD, T9600, ["?f"] ' Clear screen start at leftmost cell
pause 50
Serout LCD, T9600, ["READY"]
pause 1000
DO WHILE (1)
Serout LCD, T9600, ["?f"] ' Clear screen start at leftmost cell
SwitchNum = GPIO & %00001110 'Capture GPIO(1,2,3) binary value
SwitchNum = SwitchNum >> 1
Serout LCD, T9600, [#SwitchNum]
Pause 50
LOOP
Goto mainloop ' Do it forever
End
Bookmarks