Port settings - 18F4620


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    583

    Default Port settings - 18F4620

    Guy's I'm a bit rusty, can someone confirm that the following settings turns off all analogue settings and makes port A digital

    Code:
    ;----[Analog Settings]----------------------------------------------------------
    INCLUDE "alldigital.pbp"                        ' make all pins digital
    
    ;----[Port settings]------------------------------------------------------------
    
    TRISA = %11000111
    TRISB = %00000000
    TRISD = %00000001
    CMCON = 7                                       ' disable Comparators
    ADCON1 = $0F                                    ' %0000 1111 AN2=VSS, AN3=VDD, AN12-0 = Digital 
    ADCON2 = $00                                    ' %0000 0000
    Should ADCON1 be set to $00 ? or does the all digital.php override these settings ?

    I want to use PORTA.0, PORTA.1 and PORTA.2 as digital inputs from switches -
    Last edited by Scampy; - 18th November 2015 at 22:12.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Port settings - 18F4620

    Hi,

    CMCON = 7 is correct for the 18F4620 but it's also the POR default so it's not REALLY needed.
    ADCON1 = 15 is correct if all pins should be digital, if you set it to 0 all 12 inputs will be analog.
    ADCON2 doesn't really matter since the ADC is off anyway.

    I've never used Darrels AllDigital but remember that when you INCLUDE a file like that the content of the file will be put in at that very spot - just as if it was actually typed in right there. Since you include it first and THEN set CMCON etc manually YOU will overwrite whatever it is IT does to the relevant registers. Had YOU set the registers first and THEN included AllDigital IT would overwrite anything you've set manually - in the register it believes are important only of course.

    /Henrik.

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Port settings - 18F4620

    Thanks Henrik,

    I think that I'll remove any manual settings and add the AllDigital include file at the start of all my project that have no analogue requirements - makes things simple

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Port settings - 18F4620

    You can do that - as long as the chip is "supported" by AllDigital. How do you know if a certain chip is supported? I don't know, you'd need to read the code for AllDigital and compare it to the datasheet for the device - which kind of defeats the purpose of AllDigital.

    I guess any chip released prior to AllDigital will be handled and possibly a lot of later chips as well but don't take anything for granted.

    Or you can do it manually and learn something in the process - perhaps you get so good at it that you can maintain AllDigital and keep it up to date.

    /Henrik.

Similar Threads

  1. Serial port settings for given crystal
    By Scampy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 15th December 2013, 22:11
  2. 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
  3. 18f4620
    By Moldava in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 28th January 2010, 08:18
  4. ADCON1 settings 18F4620
    By earltyso in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th February 2008, 06:56
  5. Duplicating port input to port output
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th April 2004, 21:43

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