i am having problem with RB6 pin in PIC16F877a

Discussion in 'Embedded Systems and Microcontrollers' started by viccram, Jul 8, 2008.

  1. viccram

    Thread Starter New Member

    Jul 8, 2008
    i am using pin no. 39 (RB6) as a i/p from limit switch in my robot... on pressing the switch the motor is supposed to stop but the motor does not stop sometimes (eg. the case is once in every 10 times) . interrupt on change feature is enabled.

    while using other three pins(RB4-RB7 exvept RB6) as input the system has no problem...but when i use this pin as input the system doesnt always work properly.....

    the input is a pulled up pin with a switch connected to ground.. when i press the switch pin goes low else normally high (as it is pulled up to Vcc)...
    the problem is that when i press the switch the pin goes low(around .023V) but as i leave the switch the pin still remains low (around .16V to .189V)
    i hav tested the switch and the circuit noise level as well....
    switch is fine and the circuit noise level is around 600mV...
    how much noise prone is PIC?
    and Registers should i think of while initializing pin RB6 as input
    RB6 is used as PGD in programming...so is this problem related to this typical feature of the pin???

    i think its not a basic circuit problem....is it because of spikes in motor that is producing noise in circuit...or is there any probability that the PIC goes into to some other mode (like sleep or BOR or WDT timer problem may be...)
    but i have used this configuration word in program


    i am using a 11.0592Mhz Xtal....does PIC 16F877a support this xtal???
    am i using "HS" the right term for this XTAL???
  2. jut

    AAC Fanatic!

    Aug 25, 2007
    Please post a circuit diagram of the input connected to RB6.

    I'm guessing RB6 is not configured correctly in your code.

    From the datasheet:
    "To enable weak pull-ups, set the appropriate TRIS bit(s) and clear the RBPU bit (OPTION_REG<7>)."

    What is the value of register TRISB?
    What is the value of register OPTION_REG?

    Are you using C or assembly?

    Please not that people would be more apt to reply if you are clear and concise as possible when describing your problem.