Sorry, I guess I wasn't very clear. I'm just playing around with ADCs on PortA, not doing anything with PortC. I'm using a EasyPIC3 development board so LEDs are available on all pins. I'm aware the 1 means input and that as an input the pin may float above 0V but I was under the impression that it should not have enough power to drive an LED when set as an input. None of the other pins on PortC drive the LEDs but C.7 is bright. Using melabs U2 Programmer to program the MCU; set MCU to 16F887, Oscillator to XT, all other fuses to default. LCD, ADCs work as expected, just this C.7 thing is odd and just do to my ignorance.
Code:
' Define LCD pins
DEFINE LCD_DREG PORTB ' Sets LCD Data Port to Port-B instead of default Port A
DEFINE LCD_DBIT 4 ' Sets for use of PortB bits 4 thru 7 for the data
DEFINE LCD_RSREG PORTB ' Sets RS (Register Select) to Port B instead of default PortA.4
DEFINE LCD_RSBIT 2 ' Sets RS (Register Select) to bit 2 of port B (PORTB.2)
' ' Enable stays at the default PORTB.3
ANSELH = 0
ANSEL = 0 ' This sets the ADCs to Digital
Low PORTB.2 ' LCD R/W line low (W)
Pause 2000 ' Wait 2 seconds (2000 mS)for LCD to start
Lcdout $fe, 1, "16F887 ADC Test" ' Display sign-on message
TRISC = %1111111
DEFINE ADC_BITS 10 ' 10 bit A/D Conversion
ANSELH = 0
ANSEL = %00001100 ' Set pin (AN2, AN3) to analog input, the rest to digital
ADCON1 = %10000000 ' Set up A/D converter - Right Just., VDD REF.
adc_val var word
adc_val_2 var word
pause 2000 'settle
mainloop:
ADCIN 2, adc_val ' Get ADC value from ADC channel 2
ADCIN 3, adc_val_2 ' Get ADC value from ADC channel 3
Lcdout $fe, 1, DEC (adc_val)," ADC 1 Value"
Lcdout $fe, $C0, DEC (adc_val_2)," ADC 2 Value"
Pause 200
goto mainloop
End
Bookmarks