+ Reply to Thread
Results 1 to 7 of 7

Thread: Configuration switch to set PORTB as digital in 18F2XXX

  1. #1
    Licensed User yvesmazzon's Avatar
    Join Date
    Jul 2006
    Location
    Ghana/Zimbabwe
    Posts
    50

    Default Configuration switch to set PORTB as digital in 18F2XXX

    Dear Picster,
    I'm battling to get the PORTB as digital only. I'm using a 16F2585 chip. but I'm not getting the weak pull up effectively. I have configured as follow:

    Device = 18F2585
    Xtal = 20 ' Set Xtal Frequency

    Config_Start
    OSC = HS
    PBADEN = off ' PORTB<4> and PORTB<1:0> Configured as Digital I/O Pins on Reset
    WDT = OFF ' HW Disabled - SW Controlled
    Config_End

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




    All_Digital = TRUE
    PortB_Pullups = On 'Enable to have port B set with a weak pull up
    Am I missing something?
    Regards,
    Yves


  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Licensed User pic-ignorant's Avatar
    Join Date
    Oct 2007
    Location
    Sunny Kent
    Posts
    2,125


    Default Re: Configuration switch to set PORTB as digital in 18F2XXX

    Have you looked through the datasheet to see what peripherals are on those pins, and checked their default state on POR?

  4. #3
    Licensed User yvesmazzon's Avatar
    Join Date
    Jul 2006
    Location
    Ghana/Zimbabwe
    Posts
    50


    Default Re: Configuration switch to set PORTB as digital in 18F2XXX

    yes I did over and over, and don't know what else has to be done. On a datasheet it says as follow:

    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 (CONFIG3H<1>), RB4:RB0 will
    alternatively be configured as digital inputs
    on POR.

  5. #4
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: Configuration switch to set PORTB as digital in 18F2XXX

    Hi
    it looks like you will also need to do a trisb=255
    after the portb pullups..
    Apart from that, it looks ok at first glance in the ASM.

    See example 10.2 in the datasheet under portB settings. As John says, some of the pins are set for other uses - CAN etc.
    Last edited by captainslarty; 10th March 2011 at 09:49.
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

  6. #5
    Licensed User yvesmazzon's Avatar
    Join Date
    Jul 2006
    Location
    Ghana/Zimbabwe
    Posts
    50


    Default Re: Configuration switch to set PORTB as digital in 18F2XXX

    Hi Joe,
    I have try trisb=255 as you suggested but still not working. The program I wrote is a bit long but worked perfectly with the 16F876A and I decided to upgrade the chip with the 18F2585 for more program and memory space. It seems that the the registry configuration is a mine field with the 18F chips. I'm not too experienced with all the subtility of the register. Something I learn is with Proton the ALL_Digital = true does not applies for PORTB. Am I wrong? Any more idea?
    Regards,
    Yves
    For the small story. My cats was fascinated with you bug logo. I had to push it away before he start scratching my laptop screen. I suppose that was the only interesting thing he could find on the screen, smile.

  7. #6
    Licensed User captainslarty's Avatar
    Join Date
    Sep 2006
    Location
    A Marina in Portugal
    Posts
    3,064


    Default Re: Configuration switch to set PORTB as digital in 18F2XXX

    Hi Sir, sorry about the cat attracting bug huha
    Again, I have not looked too deeply into this specific chip,
    but the asm

    PROTON#CODE#START
    ORG 0
    GOTO PROTON#MAIN#START
    ORG 8
    PROTON#MAIN#START
    CLRF 4088,0
    CLRF 4011,0
    MOVLB 0
    F2_SOF EQU $ ; USB.PRP
    F2_EOF EQU $ ; USB.PRP
    F1_SOF EQU $ ; USB.BAS
    F1_000039 EQU $ ; IN [USB.BAS] ALL_DIGITAL = TRUE
    MOVLW 7
    MOVWF ADCON1,0
    F1_000040 EQU $ ; IN [USB.BAS] PORTB_PULLUPS = ON
    BCF INTCON2,7,0

    'Seems' to conform ok.
    (ALL DIGITAL = TRUE) does not set all pins as you may think (on some devices).. it does though, in this case, appear to set as per datasheet... which is only certain pins on portB.
    One thing I would suggest, is to look at ALL config settings, not just a few, in other word make usre you set ALL config fuses.
    PortB uses some of the pins for CAN. etc.

    If you could mail me your full code, I might be able to look at the code and see if I can help, but as said, I am not familiar with this device at all, purely a quick look at the datasheet and the code / asm.
    Joe
    Civilisation is the limitless mutiplication of unecessary necessities ... (Mark Twain)

  8. #7
    Licensed User yvesmazzon's Avatar
    Join Date
    Jul 2006
    Location
    Ghana/Zimbabwe
    Posts
    50


    Default Re: Configuration switch to set PORTB as digital in 18F2XXX

    Hi Joe,
    I gave up so I changed my press button away of B0 - B1 and placed them at B6 - B7 and now I have the internal pull up I wanted,
    many thanks for your time.
    Regards,
    Yves

+ Reply to Thread

Similar Threads

  1. LCD on portb
    By savnik in forum Proton Plus Compiler v3
    Replies: 12
    Last Post: 14th February 2009, 00:08
  2. reading PORTB
    By heliaddict in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 22nd November 2008, 19:04
  3. Can't use PORTB.4 for output
    By Don Stratton in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 8th March 2006, 07:26
  4. Hi. How I can do this: portb.[Led] = x
    By Kuervo in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 24th November 2005, 10:21
  5. Confused about portb
    By David Blackburn in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 3rd June 2005, 20:50

Members who have read this thread : 9

Actions :  (Set Date)

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