Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Unusual issue with PIC16f628a

  1. Apr 26, 2010 #1
    Hi,
    So I have this strange issue with 16f628a. If I connect RB4 it to +5V, everything hangs, all ports go to 0. It does that no matter whether it is set to input or output.

    My program is very complex, so to make sure that it is not because of a logical mistake, I tried with this simple program instead - http://pastebin.com/mDNvixWv . The problem stays.

    Is there some sort of trick for this port/controller that I don't know of or am I mistaking somewhere?
     
  2. jcsd
  3. Apr 26, 2010 #2

    Averagesupernova

    User Avatar
    Science Advisor
    Gold Member

    I don't have time at the moment to look at a data sheet to see everything that this port is capable of doing. My first hunch would be that you need to change something in the configuration bits. This port is probably not set up to do what you think it is.
     
  4. Apr 26, 2010 #3
  5. Apr 26, 2010 #4

    Averagesupernova

    User Avatar
    Science Advisor
    Gold Member

    Are you familiar with the configuration bits on PICs? It isn't part of the executable program. They are registers that are set upon programming and cannot be changed during execution.
     
  6. Apr 26, 2010 #5
    I am familiar with them. But until then I did not know that RB4 can be used only if LVP is disabled trough a configuration bit as you suggested.
    So adding _LVP_OFF to my _CONFIGURE line fixed this for me.

    Thank you very much again and all the best.
     
  7. Apr 26, 2010 #6

    Averagesupernova

    User Avatar
    Science Advisor
    Gold Member

    You are quite welcome. When I first got started with PICs I decided it is a good idea to configure EVERYTHING even if I didn't think it needed to be in my specific application. Something always come up later so I decided it was just a good idea to list everything in the configure line right away. Maybe it's my obsessive-compulsive nature, but I hate 'loose ends'.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook