18F14K50, PORT C as outputs


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Feb 2012
    Posts
    57

    Default 18F14K50, PORT C as outputs

    Maybe this is a stupid question, already answered before, but I could not find the answer...

    I am trying to use PORTC of a PIC18F14K50 as outputs.
    To do so, I use:

    ANSEL = 0
    ANSELH= 0
    TRISC = 0
    PORTC = 0

    IMHO this should configure PORTC as digital and set the outputs of PORTC low.
    But it seems I can still pull the pins easily to high, using a resistor.
    This gives me the impression that the pins are still inputs!
    What am I overlooking?

  2. #2
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    port c has comparator outputs i would set them to 0 as well

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    refer page 95-97 of data sheet , comparitor take priority over data i/o

  4. #4
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Isn't that what I am doing with ANSEL and ANSELH ? Or am I still missing something?

  5. #5
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    This is register values that I used to turn off all analog stuff.
    Code:
            REFCON0=0
            REFCON1=0
            ADCON1=0
            ADCON2=0
            ANSEL =0           
            ANSELH=0
            CM1CON0=0
            CM2CON0=0
            SRCON0=0
            SRCON1=0
            WPUA=0
            WPUB=0

  6. #6
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Thanks! I will try that and report the results!

  7. #7
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Mmm... I tried this but it still doesn't work!
    Code:
    REFCON0=0
    REFCON1=0
    ADCON1=0
    ADCON2=0
    ANSEL =0           
    ANSELH=0
    CM1CON0=0
    CM2CON0=0
    SRCON0=0
    SRCON1=0
    WPUA=0
    WPUB=0
    
    TRISC = 0
    PORTC = 0
    
    ProgStart:
       PORTC.2 = 1
       pause 1000
       PORTC.2 = 0
       pause 1000
       goto ProgStart

  8. #8
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Are you sure that problems are in portc?
    Did you test other port? Maybe you didn't configure oscillator correct, or MCLR pin, etc...

  9. #9
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Yes, when I use PORTB everything is fine!
    (I can pull the C-outputs still high with a resistor. This gives me the impression that the pins are inputs.)
    Last edited by RuudNL; - 1st September 2014 at 14:43.

  10. #10
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    What value are resistor?
    Try to put LED on portc with 1K series resistor, then see what is happening...

  11. #11
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    The result is (as expected): nothing!

  12. #12
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    PORTC is probably damaged...
    You can try to use LAT registers, but...

  13. #13
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    PORTC is probably damaged...
    I don't think so, because the result is the same with different (new!) 18F14K50's...

  14. #14
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    New test:

    Code:
    REFCON0=0
    REFCON1=0
    ADCON1=0
    ADCON2=0
    ANSEL =0           
    ANSELH=0
    CM1CON0=0
    CM2CON0=0
    SRCON0=0
    SRCON1=0
    WPUA=0
    WPUB=0
    
    TRISC = 0
    PORTC = 0
    
    ProgStart:
       PORTC = 0
       pause 1000
       PORTC = 255
       pause 1000
       goto ProgStart
    PORTC.3, C.6 and C.7 work, PORTC.0, C.1, C.2. C4 and C.5 don't...
    So... what's the common factor?

  15. #15
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Hi,
    I've been looking thru the datasheet to figure out what might be going on but I honestly can't find it.
    So, I'm going to sugest that you might have a hardware issue, is this on a breadboard by any chance? Faulty contacts?

    Going thru the datasheet I also noted the follwing regarding setting all those registers to 0 in your code:

    REFCON0=0 (pg.247)
    Defaults to 16 at POR which means that the FVR is set to 1.024V but disabled, setting it to 0 shouldn't be needed.
    Instead, it specifically says not to use the value 0....

    REFCON1=0 (pg.248)
    Defaults to 0 at POR, DAC disabled, setting it to 0 shouldn't be needed.

    ADCON1=0 (pg.216)
    Defaults to 0 at POR, setting it to 0 shouldn't be needed.

    ADCON2=0 (pg.217)
    Defaults to 0 at POR, setting it to 0 shouldn't be needed.

    ANSEL = 0 (pg.98)
    Defaults to 248 at POR, setting it to 0 IS needed to enable the digital input buffers.

    ANSELH = 0 (pg.99)
    Defaults to 15 at POR, setting it to 0 IS needed to enable the digital input buffers.

    CM1CON0=0 (pg.229)
    Defaults to 0 at POR, comparator is disabled, setting it to 0 shouldn't be needed.

    CM2CON0=0 (pg.230)
    Defaults to 0 at POR, comparator is disabled, setting it to 0 shouldn't be needed.

    SRCON0=0 (pg.242)
    Defaults to 0 at POR, SR latch is disabled, setting it to 0 shouldn't be needed.

    SRCON1=0 (pg.243)
    Defaults to 0 at POR, SR latch is disabled, setting it to 0 shouldn't be needed.

    WPUA=0 (pg.86)
    Defaults to 56 at POR, PortA pulups enabled, setting it to 0 disables the pullups individually.
    However, INTCON2.7 is the "master switch" PortA and PortB pullups and it defaults to 1 which means pullups are disabled.
    So, if you're NOT clearing INTCON2.7 there shouldn't be any need to set WPUA=0

    WPUB=0 (pg.91)
    Defaults to 240 at POR, PortB pullups enabled, setting it to 0 disables the pullups individually.
    However, INTCON2.7 is the "master switch" PortA and PortB pullups and defaults to 1 which means pullups are disabled.
    So, if you're NOT clearing INTCON2.7 there shouldn't be any need to set WPUA=0

    /Henrik.

  16. #16
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Thank you Henrik for your time and effort.
    I think you are right, setting states that are the same as after POR are not very useful...
    I think I give up for today. Tomorrow there's an other day...

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


    Did you find this post helpful? Yes | No

    Default Re: 18F14K50, PORT C as outputs

    Have you tried AllDigital?

    http://www.picbasic.co.uk/forum/showthread.php?t=11100

    Robert

Similar Threads

  1. 18f14k50 low speed
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st May 2013, 18:20
  2. Hello World help please 18F14K50 config
    By Bonxy in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th August 2011, 17:35
  3. Replies: 2
    Last Post: - 22nd January 2011, 01:58
  4. 18F2520 - problem configuring fuse for port B as digital port.
    By hwhisperer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th October 2010, 11:41
  5. Replies: 3
    Last Post: - 24th September 2010, 07:10

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