PIC 18f4680 DIGITAL INPUTS


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jun 2004
    Posts
    43

    Unhappy PIC 18f4680 DIGITAL INPUTS

    Hello ! I have a problem working with registers of pic18f4680
    I want all pins on all ports as digital IO ( except MCLR which I configured as MCLR , not IO ) . I just can't make it, I've read the datasheet a lot, but no success. I make some ports digital configuring ADCON1 and INTCON , fut he others are turning to analog and so on. I need them all digital IO's.
    Thank you very much for your support.

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


    Did you find this post helpful? Yes | No

    Default

    As i remind those line should help
    Code:
    CMCON = 7
    ADCON1 = $0F
    Steve

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

  3. #3
    Join Date
    Jun 2004
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Thanks for reply man, but it's not enough ! I am using theese two lines also

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Datasheet...

    Section 10... let's look at this Port by Port...

    PortA

    Look at Table 10-2... immediately you can see you need to Disable Comparators, Voltage Reference Module and ADC's...

    Jump to Comparator Module, see Register 20-1 and Figure 20-1 from those you can determine to knock-out the Comparators you don't need...

    CMCON=%00000111

    The Comparator has a Voltage Reference Module... jump to Register 21-1 and make sure it's OFF...

    CRVCON=%00000000

    Next, kill the ADC's...

    Section 19 for ADC's, Register 19-1...

    ADCON0=%00000000

    and Register 19-2 make your selection from the table...

    ADCON1=%00001111

    All you're left with is configuring TRISA for your I/O application...

    Now go back to Section 10 for...

    PortB

    Table 10-4 tells you ADC's affect this Port, but you've probably killed them with the ADCON statements you did above at PortA.

    PortC

    Table 10-6 tells us PortC has no issues...

    PortD

    Table 10-8 tells us that PortD has PWM's and a Parallel Slave Port.

    By default, PWM's don't affect us - but if you want to be safe...

    ECCP1CON=%00000000

    A look at PSPMODE bit 4 of TRISE (OK, I didn't build this chip, so don't moan at me for having to look in TRISE for a PORTD control Bit), at Section 10-5 TRISE Register 10-1 on Page 142 tells us you need this bit to be ZERO for General Purpose I/O...

    TRISE.4=0

    PortE

    Table 10-10 tells us that Comparators and ADC's affect this Port. But, you've probably switched them off back above at PortA stage...

    OK... is there a problem?

    PS, please keep problems on the forum...

  5. #5
    Join Date
    Jun 2004
    Posts
    43


    Did you find this post helpful? Yes | No

    Thumbs up

    Thank you very much Melanie for your support .

  6. #6
    Join Date
    Mar 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Port D input

    Hi,

    just ported a program from 16F877 to this PIC. And Port D refuses to act as an input.
    I tried the following program snippet:

    ECCP1CON=%00000000
    TRISE.4=0
    TRISD=%0001111

    IF PORTD.2=1 THEN
    HIGH beeper
    PAUSE 1000
    LOW beeper
    ENDIF

    I put a 1k resistor from Vdd (5V) to port D2. The beeper doesn't sound. When I change the conditional statement to "PORTD.2=0",then the beeper sounds, even with the resistor connected! I checked for shorts, and no there is no short from D2 to GND.
    I also tried ports D1 and D3: same result...
    For some reason ports D refuse to become input and stay output low.....

    Another funny thing is that I use PortA0 as AD converter. If I connect 3V to this port, the PIC heats up like crazy (not so with the same PCB and 16F877)
    When I put a 100k in series with this pin, the AD works OK and PIC doesn't heat up.
    So also this pin acts as active low, even in AD mode....


    Any ideas what more to try?

Similar Threads

  1. Setting up digital inputs
    By quester in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd March 2008, 22:14
  2. Pic driven digital audio delay
    By skimask in forum Off Topic
    Replies: 12
    Last Post: - 19th April 2007, 20:42
  3. inputs on 12F675 (or for that matter any PIC)
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th April 2007, 19:43
  4. Using portb as inputs PIC goes crazy
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th November 2005, 14:15
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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