18F2520 - problem configuring fuse for port B as digital port.


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    7

    Lightbulb 18F2520 - problem configuring fuse for port B as digital port.

    Hi to all...

    sorry for my english, I'm italian and now I work and live in Bulgaria.

    this is the first time I post someting but... I used many times the informations that come from your forum... :-)

    Now, I have a problem migrating some my projects born for 16F876 to 18F2520.
    I use PBP 2.46 and I need to configure the fuse for have pins 0-4 in port B as digital input at reset.

    I used the configuration scheme that Melanie suggests in her post n.2358:

    @ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_PORTC_3H
    ' MCLR is OFF (internal)
    ' PortB 4:0 is digital on Reset
    ' CCP2 is Multiplexed with PortC.1

    ...butchered in this way:

    @ __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H & _CCP2MX_PORTC_3H
    ' MCLR is ON
    ' PortB 4:0 is digital on Reset
    ' CCP2 is Multiplexed with PortC.1

    ...becouse I want use MCLR in external way.

    The problem is that it dont works and pins 0-4 in port B still work as analogic input...

    There is someting wrong?
    Maybe I forget someting...

    Thankyou in advance.

    Stefano

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    You need to get into the data sheet for your PIC18F2520. and read how to set the registers. They control whether the ports are analog or digital.
    You have ADCON0, ADCON1,ADCON2, ADRESH, ADRESL, CCP REGISTER . . .
    THIS IS FROM THE DATA SHEET . . .
    Code:
    Note: On a Power-on Reset, RB4:RB0 are
    configured as analog inputs by default and
    read as ‘0’; RB7:RB5 are configured as
    digital inputs.
    By programming the configuration bit,
    PBADEN, RB4:RB0 will alternatively be
    configured as digital inputs on POR.
    I "THINK" this means PBADEN should be on.
    hth
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Oct 2010
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Yes, thanks... Now it works... I had to configure properly the bits in ADCON1.
    My mistake was to think that, using the CONFIG, it was automatically done...

    stefano

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