16F877 Wackiness


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2009
    Posts
    8

    Default 16F877 Wackiness

    I've got a strange problem with a PIC. When I set a pin high, say PORTB.7, then try to bring it low after a second or two, the pin will stay high. This is the first time I've seen this after a few years of using PICs.

    This happens with PORTA and B. Maybe the others. The strange part is that the pins will work fine for a while, then stay high. This PIC was working ok for a few months, now this.

    I've placed the PIC in a basic circuit to test it. (The same basic circuit I've been using for years)

    Here's the code I'm testing with. Has anyone ever had this happen?

    Code:
    mainloop: High PORTB.7        ' Turn on LED connected to PORTB.7
            Pause 1000       ' Delay for one second
    
            Low PORTB.7           ' Turn off LED connected to PORTB.7
            Pause 1000       ' Delay for one second
    
            Goto mainloop   ' Go back to loop and blink LED forever
            End
    
            ' PORTB.7 stays high.
            ' If I re-program it a few times, it comes back for a while.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I have seen PortB.7 on an 18F2420 when used as an INPUT read LOW (internally) and stay low despite external pull-up Resistors, Car Jacks and Cranes pulling the pin up (externally a scope shows the pin correctly as HIGH). Restarting the PIC causes the pin to read HIGH (as it should) but once pulled low it locks LOW until you restart again. Erasing and Reprogramming the PIC (with exactly the same program) clears the problem. This anomally has appeared on about 70-80 PICs out of about 1500 for this product (but only in the last two years) and that pin is used in less than 1% of total. I've not had time to investigate further as the particular product it goes into is pretty much at end-of-life.

    I mention the above, because the 18F2420 is part of the family progression of the 16F876/877.

    Try Erasing and Reprogramming the PIC.

    Also have you remembered to set TRISB.7 for OUTPUT?

  3. #3
    Join Date
    Oct 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    That's good to know that I'm not the only one to experience this. I've ordered a few new PICs.

    I'll reprogram and set TRISB.7 = 1 as well.

    Thank you.

  4. #4
    Join Date
    Oct 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    I mean TRISB.7 = 0

  5. #5
    Join Date
    Oct 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    I found the problem. My 9V battery was low. I swapped it for a fresh one and that fixed it. I can duplicate the problem by swapping in the old one.

    Now my next question. What should I use to power my ciruit? I'm using a 7805, and I'm driving a couple of servos, so I kill the 9V batteries quickly.

    I looked at a few 9V AC to DC power supplies that I had lying around, but not enough amps I guess. The servos don't move like they should. A fresh 9V drives them at at first but run out quickly.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dino308gt4 View Post
    I found the problem. My 9V battery was low. I swapped it for a fresh one and that fixed it. I can duplicate the problem by swapping in the old one.

    Now my next question. What should I use to power my ciruit? I'm using a 7805, and I'm driving a couple of servos, so I kill the 9V batteries quickly.

    I looked at a few 9V AC to DC power supplies that I had lying around, but not enough amps I guess. The servos don't move like they should. A fresh 9V drives them at at first but run out quickly.
    So many options...
    A 9 volt Wall Wart with a 500ma output will do just about everything the 7805 will handle. I keep a few 12 Wall Warts around for a quickie. A capacitor across the rails is sometimes needed as some of the Warts are pretty dirty.

    A battery pack with 4 AA rechargeable and no regulator. Non rechargeable have to high voltage to run straight.

    If you are going to be doing this often (working on PICs and things) a good bench top power supply is the answer.

    Whatever you use, be sure to have a a fuse, smaller the better, as near to the source as possible.
    Dave
    Always wear safety glasses while programming.

  7. #7


    Did you find this post helpful? Yes | No

    Red face

    Hi
    I have jumped on to use a 16F877A, Its the first time I am trying to use an external oscillator : Can you please give me the values you have used for the capacitors which are Grounding the Osc1 & Osc2. I have an 2 Pin ceramic 4MHz Oscillator connect between Osc1 & Osc 2
    Thanks
    ___________________
    WHY things get boring when they work just fine?

  8. #8
    Join Date
    Oct 2009
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by financecatalyst View Post
    Hi
    I have jumped on to use a 16F877A, Its the first time I am trying to use an external oscillator : Can you please give me the values you have used for the capacitors which are Grounding the Osc1 & Osc2. I have an 2 Pin ceramic 4MHz Oscillator connect between Osc1 & Osc 2
    Thanks
    I use a pair of 22pf caps.

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Thanks for the input. I have followed and something very strange is happening :

    I am using an external oscillator 4MHz. My program simply toggles one pin every 30ms.
    Problem is that I see sometimes the toggling if I touch the PIC,leg of the capacitor (earth) or touch the bench the circuit is left on and sometimes it works fine and sometimes the led is just on constantly.

    I have never ever seen this happening with any PIC I have used till now. What could be the reason for this??? Any advise ????
    ___________________
    WHY things get boring when they work just fine?

Similar Threads

  1. 16f877 and ps/2 keyboard error???
    By boraciner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th July 2009, 08:14
  2. serial communication between CMUcam and PIC 16F877
    By gengkeys in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th March 2007, 06:43
  3. 4 Quadrant dc drive with 16F877
    By mns45 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 23rd February 2006, 13:05
  4. Compatibility in between 16f877 and 18f452
    By BIDOUILLE in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th October 2005, 13:59
  5. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47

Members who have read this thread : 0

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