16F887 PORTC.7 high


Results 1 to 9 of 9

Threaded View

  1. #3
    Join Date
    May 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    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
    Last edited by Neosec; - 31st March 2013 at 13:59.

Similar Threads

  1. 16f887 portc input problems
    By lockjawz in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st March 2011, 14:02
  2. Can't get RC2 to go high with PORTC.2 = 1
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th September 2009, 07:26
  3. high voltage high frequency H-Bridge
    By George in forum Off Topic
    Replies: 6
    Last Post: - 27th April 2009, 11:50
  4. 18f4550 portc.4 and portc.5 problem
    By pcaccia in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th October 2008, 20:52
  5. 16f877 portc.6 & portc.7
    By DavyJones in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 12th January 2008, 04:38

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts