Anyone ever run into an issue with activating the pullups on Port E pins on the 18F66J16? Seems setting PORTG.6 doesn't do the trick. No difference on the output of Port E output pins when G.6 is set or not, voltage is only about 250 mV max. Drops to 0 when the switch is activated (pulled to ground), then increases to about 40 mV as it slowly draws up. I also tried to read PORTG.6 back to see the state, and it says it's not set, reads a 0.
Anyway, here's the code, unadulterated. I'm using the SSD1339 OLED GLCD for debugging, it's nice using that instead of stringing serial port wires to other PCs when doing the debug. Any suggestions??
Code: Select all
Device = 18F66J16
Clock = 32
Include "GLCD.bas"
Include "ssd1339.bas"
Include "Verdana.bas"
Include "convert.bas"
Include "system.bas"
Function CheckButton(ByRef aPin As Boolean) As Boolean
result = aPin //used this method to check pin - didn't make any difference
End Function
Config Fosc = intoscpll //use internal PLL
Dim Power_LED As PORTC.0
output(portc.0)
Dim
S0 As PORTE.booleans(0), //tried setting port 0 to bool to see if it showed the status correctly - measuring V showed it does
S1 As PORTE.1,
S2 As PORTE.2,
S3 As PORTE.3,
S4 As PORTE.4
OSCTUNE.6 = 1 //turn on the PLL for 32 MHz with intosc
OSCCON.6 = 1
OSCCON.5 = 1
OSCCON.4 = 1
TRISA = %00001101 ' Configure PORTA pins As inputs And outputs
TRISB = %11000011 ' Configure PORTB
TRISD = %00000000 ' Configure PORTD as outputs for diplay
TRISE = %00011111 ' Configure PORTE as inputs for switches, outputs for display control
TRISF = %01111111 ' Configure PORTF as inputs
TRISG = %11011100 ' Configure PORTG as inputs for switches, outputs for display control
Input(PORTE.0) //tried setting these switch inputs again to see if it worked - apparentlyl it does not
Input(PORTE.1)
Input(PORTE.2)
Input(PORTE.3)
Input(PORTE.4)
High (PORTG.6) // Enable the pull-ups on Port E (switches)
High (PORTG.7) // Enable the pull-ups on Port D (display data)
// Initialize display
GLCD.Brush.Color = $00
Pen.Color = $DA
OLEDPower //set up the OLED for powering up
QPWR = 1 'turn on high voltage supply
{ ASM
CLRF PORTG
CLRF LATG
MOVLW D4
MOVWF TRISG
End ASM } 'here's where I tried using assembler to set G.6
//wait 5 seconds for supercaps to charge up
InitializeOLED //put initialize here to ensure 5V initialization occurs before high V is turned on
Cls(0,0,132,132) //clear entire screen
GLCD.SetFont(VerdanaBold)
GLCD.WriteAt(0,2,"Powered Up")
i=0
If CheckButton(S0) Then
GLCD.WriteAt(0,15,"S0 is high ")
Else
GLCD.WriteAt(0,15,"S0 is low ")
EndIf
GLCD.WriteAt(0,28,"G =",HexToStr(PORTG.6)) //Here's where I get the status back of G.6)
GLCD.WriteAt(0,41,"S2 =",HexToStr(PORTE.2))
GLCD.WriteAt(0,54,"S3 =",HexToStr(PORTE.3))
GLCD.WriteAt(0,67,"S4 =",HexToStr(PORTE.4))
Power_LED = 0
GoTo check_switches