PortD on 18f4550 cofig pullup for switches


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77

    Question PortD on 18f4550 cofig pullup for switches

    Hi all

    I have a 18f4550 and want to have port D as inputs and connect switches to portd.1 - portd.6

    I think i need to set portE.7 to enable portD pullups ??? (porte.7 = 1) ???

    the switches will be from the portD pin to ground (active low)

    I do not want to use external pullup resistors


    Any ideas please :-)
    Reading the datasheet & understanding it are two different things.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Datasheet have to be your friend.

    Step #1: Download the datasheet
    http://ww1.microchip.com/downloads/e...Doc/39632D.pdf

    Step #2: Go to table 1-3, and there, you discover that weak pull-ups are only available on PORTB

    Step #3: make a decision, use external ones, or move on PORTB.
    Case you move on PORTB, you go to section 10.2, then you discover
    Each of the PORTB pins has a weak internal pull-up. A
    single control bit can turn on all the pull-ups. This is
    performed by clearing bit, RBPU (INTCON2<7>). The
    weak pull-up is automatically turned off when the port
    pin is configured as an output. The pull-ups are
    disabled on a Power-on Reset.
    You could still decide to don't use any pull-up, or pull-down, it's doable, and if your software is properly done, you can even attach 2 push button per I/O (one to vdd, the other to Vss) ... it will work, but a real waste of time IMHO.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77


    Did you find this post helpful? Yes | No

    Red face

    Hi Steve

    I read the datasheet before i post my message :-/, to me the datasheet says that bit7 on port E set the pull-ups for portD on 18f4550 ?.

    Anyway, i could use portB,

    I want to have switches that can be active low and active high,

    can this be done without resistors ?

    thx :-)
    Reading the datasheet & understanding it are two different things.

  4. #4


    Did you find this post helpful? Yes | No

    Default Similar story

    I have read the data sheet and have set registers as below for 4550
    TRISA = %00111111'An 0-4
    TRISB = %00011111'An 8-12
    TRISC = %00000000'All output
    TRISD = %00000000'All output
    TRISE = %00000111'An 5-7
    ADCON1 = %00000000'A/D channel All
    ADCON2 = %10000011'Right justify for 10 bit
    INTCON2 = %10000000'Set to disable pullup on An 8-12?

    I cannot disable the weak pullups on portb, can someone please show me how this is done, is pbaden involved?

    Thanks

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Ouch,mmm well , seems you're totally right, I totally missed that part, my apologies
    Each of the PORTD pins has a weak internal pull-up. A
    single control bit, RDPU (PORTE<7>), can turn on all
    the pull-ups. This is performed by setting RDPU. The
    weak pull-up is automatically turned off when the port
    pin is configured as a digital output or as one of the
    other multiplexed peripherals. The pull-ups are
    disabled on a Power-on Reset. The PORTE register is
    shown in Section 10.5 “PORTE, TRISE and LATE
    Registers”.
    PORTE.7=1 ' this will indeed enable pull-up on PORTD

    Intcon2.7=1 will disable the pull-ups as per the datasheet. (pdf page 102)

    Out of curiosity, why do you say that you're unable to disable the pull-ups? If you read some voltage from them, maybe you read some "parasitic voltage", and If I remember correctly, some of these I/O on PORTB are also set as analog at POR. See ADCON0 (p262)

    ADCON0=%00001111 ' turn of all ADCs

    You can also trick PORTB adc with the config fuses.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77


    Did you find this post helpful? Yes | No

    Talking

    Hi Steve,

    I always try the datasheets before I post a help request, the only problem with the datasheets is that they are quite technical and confusing to a dabbler like me who only program for fun.

    Anyway, I think i got the active low switch working now, the switch is connected to ground and port pin and it works,

    BUT, How do I get a switch to work active high now ?,

    I connect the switch to +5v and port pin (it trigger the switch once but do not go back low)

    how can i get this to work ? any ideas :-)
    Reading the datasheet & understanding it are two different things.

  7. #7


    Did you find this post helpful? Yes | No

    Default Analog input problems resolved

    Thanks for your/and others invaluable help in guiding me along.

    The faulty analog inputs an8, an9 and an12 when connected to a pot 0-5v would, when the applied voltage was reduced, indicate the correct voltage until the voltage went down to 1.5v. I then connected a milliamp meter in circuit with the analog input and measured a current of 1.6 ma. After reading the sbc44 manual I now believe these inputs cannot be used as analog inputs but can be used as digital i/o? I do however have 10 analog inputs that work correctly, as I shall be using lm35/ad22100 to measure temperatures, hopefully.

    PS I have now succeeded in getting pc vb2005 to usb pic4550 and believe I now understand how it works. Does upgrading to vb2008 express give any problems?

    Tom

Similar Threads

  1. 18F4550 to 18F2550
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th September 2007, 23:13
  2. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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