• AVR Freaks

Hot!PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O.

Page: 12 > Showing page 1 of 2
Author
danbakana
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2012/08/27 05:21:28
  • Location: 0
  • Status: offline
2019/11/14 08:41:04 (permalink)
0

PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O.

In the device I'm using there is a PIC18F4550 44-Pin TQFP package , I'm using Pickit3 as programmer and I'm having problems to use pin 15 - RB5/KBI1/PGM as I/O. In this device, this pin is connected to a keyboard and I need to read it, The problem is that the resistance of button of the keyboard vary depending on the age and model. So, the low level that should be present at this pin when I pull the button is not detected by the microcontroller, instead, it seems that the microcontroller is pulling this pin high even being it previously programmed as input. 
 
EDITED:I read that I can fix it by disabling LVP Configuration bit( That, as I could see, is set 1 by default). In the datasheet says that the LVP pin can only be set or cleared when using standard high-voltage programming. But, what it means ? Does it means that I only can change it during programming and not during execution ?
Another doubt is, if I change LVP I will nedd to programm the PIC through pins ICPGC and ICPGD ? If it is true, I will have a problem because these pins are not connected in the device, they are not available
Does someone has any sugestion how can I solve this problem ?
 
EDITED2: I attached a picture of a part of the eletrica schematic. Maybe it can help. I thought there had to be a jumper to allow to switch MCLR between VDD and MCLR's programmer. Maybe, because of this, putting RB5 as input and enabling RBPU bit , is not working. What do you think ?
 

post edited by danbakana - 2019/11/26 09:21:07

Attached Image(s)

#1

20 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 12:27:28 (permalink)
    +1 (1)
    danbakana
    Another doubt is, if I change LVP I will nedd to programm the PIC through pins ICPGC and ICPGD ? If it is true, I will have a problem because these pins are not connected in the device, the are not available

    How did you program the chip in the first place?
    This is something that needs to be done when the chip is programmed.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    1and0
    Access is Denied
    • Total Posts : 9989
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 12:38:57 (permalink)
    +1 (1)
    ric
    How did you program the chip in the first place?
    This is something that needs to be done when the chip is programmed.

    I have the same question. Maybe it's pre-programmed or programmed before mounting on the board. 
     
    Continue in OP's other thread: https://www.microchip.com/forums/m1118723.aspx
    #3
    1and0
    Access is Denied
    • Total Posts : 9989
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 13:00:31 (permalink)
    0
    Make you wonder how he's going to program the PIC with his PicKit3 to change the LVP bit at runtime... huh?
    #4
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 15:44:07 (permalink)
    0
    @ric, I programmed the device using the pickit 3 via pins PGC, PGD, PGM and MCLR.
    #5
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 15:49:33 (permalink)
    +1 (1)
    danbakana
    @ric, I programmed the device using the pickit 3 via pins PGC, PGD, PGM and MCLR.

    So you CAN program the device in circuit. Just clear the LVP that way.
    You can NOT change it on the fly.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    1and0
    Access is Denied
    • Total Posts : 9989
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 16:08:02 (permalink)
    0
    danbakana
    Another doubt is, if I change LVP I will nedd to programm the PIC through pins ICPGC and ICPGD ? If it is true, I will have a problem because these pins are not connected in the device, the are not available

    So this in your Post #1 is not true.?!
    #7
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 16:12:17 (permalink)
    0
    I suspect the OP was trying to think of some way to self program the device via the ICSP pins....
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 16:14:08 (permalink)
    0
    @ric, Yes, this is the problem. With LVP set I can't use RB5 properly, so I'm having problem to read low logic level at this this pin. If I put RB5 as input, a 5V appears, probably because of the pull up that datasheet mentioned. So, I was wondering if could be possible to change it in my code, so that, in the future, I could program it using usb bootloader.
    #9
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 16:18:36 (permalink)
    +1 (1)
    Forget it. To clear the LVP bit, you're going to have to program it using the PK3.
    That is by design, to stop runaway code being able to disable LVP mode in systems that do require it.
    i.e. it's to stop devices being able to "brick" themselves.
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 16:23:12 (permalink)
    0
    1and0
    danbakana
    Another doubt is, if I change LVP I will nedd to programm the PIC through pins ICPGC and ICPGD ? If it is true, I will have a problem because these pins are not connected in the device, the are not available

    So this in your Post #1 is not true.?!


    Sorry, but why are you asking it? I will try to explain better. There are two interfaces that PIC18F4550 offers. One of them is using pins: PGC, PGD, PGM and MCLR. The other is using ICPGC, ICPGD and ICRST.
    The first is available on the interface of programming of the device, the second is not.
    post edited by danbakana - 2019/11/14 16:26:04
    #11
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 16:31:29 (permalink)
    +1 (1)
    ok, everyone missed that you added "IC" to the start of the names.
    No, you do NOT have to use those "IC" pins. You can do HV programming via the normal PGC and PGD pins.
    That is in fact the normal programming method for these old chips.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    Mysil
    Super Member
    • Total Posts : 3476
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 16:57:48 (permalink)
    +1 (1)
    Hi,
    See message in the other thread: 
    'Project Properties'  'PICkit 3'  'Option Categories:  Program Options' 
    The option to select:  'Use high voltage programming mode entry [v]' 
    seem to disappear from MPLAB X v5.25 in some cases!
     
    If this have happened to OP, there is reason to understand that he is confused.
     
        Mysil
    post edited by Mysil - 2019/11/14 17:00:51
    #13
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 17:14:17 (permalink)
    0
    @ric, let me see if I understood right. If I Clear LVP bit, by setting configuration bits in the IDE tool, I will be able to program pic only in high voltage, and I will can do it using pins PGC, PGD, PGM and MCLR, is it right ?
    So, if it is right, after it , I will be able to use RB5 as a I/O without the pull up problem?
    #14
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 17:25:59 (permalink)
    +1 (1)
    danbakana
    @ric, let me see if I understood right. If I Clear LVP bit, by setting configuration bits in the IDE tool, I will be able to program pic only in high voltage, and I will can do it using pins PGC, PGD, PGM and MCLR, is it right ?
    So, if it is right, after it , I will be able to use RB5 as a I/O without the pull up problem?

    Yes.
    Just change the LVP setting in the config bits in your source, or however you're doing it in MikroC, reprogram the chip, and you're done.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #15
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/14 17:56:37 (permalink)
    0
    ric
    danbakana
    @ric, let me see if I understood right. If I Clear LVP bit, by setting configuration bits in the IDE tool, I will be able to program pic only in high voltage, and I will can do it using pins PGC, PGD, PGM and MCLR, is it right ?
    So, if it is right, after it , I will be able to use RB5 as a I/O without the pull up problem?

    Yes.Just change the LVP setting in the config bits in your source, or however you're doing it in MikroC, reprogram the chip, and you're done.


    Nice!! I only will have access to the device again on monday. But, as soon as possible, I will inform the results here.
    #16
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/18 09:38:24 (permalink)
    0
    ric
    danbakana
    @ric, let me see if I understood right. If I Clear LVP bit, by setting configuration bits in the IDE tool, I will be able to program pic only in high voltage, and I will can do it using pins PGC, PGD, PGM and MCLR, is it right ?
    So, if it is right, after it , I will be able to use RB5 as a I/O without the pull up problem?

    Yes.
    Just change the LVP setting in the config bits in your source, or however you're doing it in MikroC, reprogram the chip, and you're done.


     
    I did the the folowing:
     
        1) Disabled the LVP (Low Voltage Program) on IDE( Mikro C for PIC) ; 
        2) Configured RB5 as input, I put TRISB = 0x27 (This is 0010 0111 in binary) ; 
     
    With this configuration, it did not work. I'm still having 5V at RB5.
     
    The datasheet, in section 10.2, says:
     
    PORTB is an 8-bit wide, bidirectional port. The corresponding data direction register is TRISB. Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input (i.e., put the corresponding output driver in a high-impedance mode).
    (...)
    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.
     
    So Idid:
        3)cleared the RBPU bit
     
    But, it did not work. This way, I'm still having 4.95V( pull-up voltage) at RB5 pin.
     
    At the end, I cleared the latch and the port, so I did:
        4)  CLRF PORTB;
        5)    CLRF LATB;
     
    After this two steps at the final, the RB5 pin stay with low voltage permanetly, as if were a output( I tested connecting an external pull-up resistor at the pin and the pin remains with 0 V)
     
    So, I don't know what to do anymore. How can I have RB5 pin as input without the 5V(internal pull-up) through it ?
     
     
     
    #17
    1and0
    Access is Denied
    • Total Posts : 9989
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/18 10:58:25 (permalink)
    0
    danbakana
    So Idid:
        3)cleared the RBPU bit
     
    But, it did not work. This way, I'm still having 4.95V( pull-up voltage) at RB5 pin.

    Clearing /RBPU bit turns ON the pull-ups.
     

    At the end, I cleared the latch and the port, so I did:
        4)  CLRF PORTB;
        5)    CLRF LATB;
     
    After this two steps at the final, the RB5 pin stay with low voltage permanetly, as if were a output( I tested connecting an external pull-up resistor at the pin and the pin remains with 0 V)

    Clearing PORTB or LATB should have NO effect on pin configured as input.
     

    So, I don't know what to do anymore. How can I have RB5 pin as input without the 5V(internal pull-up) through it ?

    Is your PICKit 3 still connected?  RB5 shares pin with the ICSP PGM pin.
     
    #18
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/18 18:59:44 (permalink)
    0

    Clearing /RBPU bit turns ON the pull-ups. 

    You right, I wrote wrong here. I set the RBPU bit. I try set and clear too, but it didn't have any difference.

    Clearing PORTB or LATB should have NO effect on pin configured as input.

    The pin was configured as input, but when I did LATB5_bit = 0; it remained "0" as I said.

     Is your PICKit 3 still connected?  RB5 shares pin with the ICSP PGM pin. 

    No, I removed PICkkt3 all times.
    post edited by danbakana - 2019/11/18 19:06:51
    #19
    danbakana
    Junior Member
    • Total Posts : 107
    • Reward points : 0
    • Joined: 2012/08/27 05:21:28
    • Location: 0
    • Status: offline
    Re: PIC18F4550 - Problem to use RB5/KBI1/PGM as I/O. 2019/11/26 09:22:14 (permalink)
    0
    I attached a picture of the MCLR circuit, maybe it can help.  I thought there had to be a jumper to allow to switch MCLR between VDD and MCLR's programmer. Maybe, because of this, putting RB5 as input and enabling RBPU bit , is not working. What do you think ?
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5