16F887 PORTC.7 high


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2008
    Posts
    31

    Default 16F887 PORTC.7 high

    I'm pretty sure this is due to the serial feature on C.7.

    I have LEDs on all port C pins and pin 7 lights the LED with TRISC = %11111111

    Is C.7 pulled high waiting for an external serial data stream to pull it low?

    RCSTA? TXSTA?

    Neo

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    For starters; 1 means input, 0 is output.

    Posting all your code wouldn't hurt either.

    Robert

    Example:
    http://www.picbasic.co.uk/forum/show...ht=tris+output
    Last edited by Demon; - 31st March 2013 at 12:52. Reason: search results

  3. #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.

  4. #4
    Join Date
    May 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    Just some more input...
    On the 16F887 PORTC.6 and PORTC.7 have a ENHANCED UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER (EUSART) feature. C.6 is labeled RC6/TX/CK and C.7 is RC7/RX/DT. I have to assume that, since I've set C.7 as in input and there's no data going out the DT line, that the RX (receiver) is holding the pin high. So, I guess my question is about the basics of the serial data feature on the MCU and why it affects this pin the way it does?

    TIA

  5. #5
    Join Date
    May 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    Tried setting RCSTA: RECEIVE STATUS AND CONTROL REGISTER to RCSTA = %00000000
    From Data Sheet -
    bit 7 SPEN: Serial Port Enable bit
    1= Serial port enabled (configures RX/DT and TX/CK pins as serial port pins)
    0= Serial port disabled (held in Reset)
    In an attempt to disable the serial port but it had no effect. C7 still high. BTW there is a 10k pull down resistor enabled on the dev. board (all of port C) and the output of C.7 is over-driving it.
    Edit: And just FYI, If I set C.7 as an output and PORTC.7 = 0 the LED goes out (off) as it should.
    Last edited by Neosec; - 31st March 2013 at 15:22.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    Try adding another 1 to your TRIS statement. It only has 7.

    TRISC = %1111111

    is the same as ...

    TRISC = %01111111

    Which puts PORTC.7 in output mode.

    Or just leave the TRIS statement out. PIC's default to all 1's for all TRIS registers.
    DT

  7. #7
    Join Date
    May 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    Good catch DT, unfortunately that didn't help.

    Edit!

    Found the Problem!!! It's the EasyPIC3 Board! I removed the PIC 16F887 and C7 Stayed on!!!

    What really helped was that the experienced people here didn't have a simple - Look dummy - answer. Not having a quick answer quickly helped solve the problem!

    Thank you all!!

    Neo

  8. #8
    Join Date
    May 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    Ok, here's a full rundown of what happened... All my fault of course, but perhaps some day someone else may have this issue or a similar one an be able to learn from my mistakes.
    The EasyPIC3 development board has jumper settings for an RS-232 interface. The pertinent one here is the RX choices of RB1, RB2, RC7. RC7 was jumpered of course. This was the first project I've worked on on this board over 18 pins on a PIC so it was never an issue before. When I first noticed the LED on I set PORTC.7 as an output and to low... LED off. All good. Then I set TRISC = %1111111 which had no effect. Right then I noticed the jumper on the RS232 port, removed it, still the LED stayed on so I discounted the jumper as a factor since it made no difference, assuming it was un-powered or floating. As Darrel pointed out I only had 7 ones for the TRISC register which caused the removal of the RS-232 jumper to have no effect! Since TRISC was set to %01111111.
    Removal of the RS-232 jumper and TRISC = %1111111 and RCSTA = %00000000 (neither of which were needed) and all's well.

    A typo and a missed jumper combined it just the right order to really complicate things.

    Thanks again

    Neo

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: 16F887 PORTC.7 high

    Thank you for taking the time to document your solution.

    Robert

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 : 1

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