Strange pic 16f877a memory loss


Closed Thread
Results 1 to 24 of 24
  1. #1
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113

    Default Strange pic 16f877a memory loss

    Hi, Well I had a really strange thing happen to my pic controller last night. For some reason or another the program was entirely erased off the pic or it became corrupted to the point it no longer functioned. I've been using the above controller with my program as a test for the past couple of months and it's been working fine without incidence until this morning that sometime in the night it died. I uploaded my program and everything is working fine now. My question would be what can cause something like this that would wipe the program out or corrupt it? Could it be the fact that almost all of the pins are wired directly to headers and nothing is tied to ground that is not in use? Could it just be a faulty pic? A little over a week ago we had a near miss on our house with lightning and we did have some damage to some electrical appliances in the home but the pic didn't seem to be affected directly at that time since it had continued to work for over a week after the storm. I didn't think the lightning damaged it but maybe a delayed damage?

    I know the controller board you will see if you follow the link above is for a 16f877 but I mounted a spare 16f877a on it, and it's always worked fine. I am careful with my program to make sure I have the correct things turned on and off for the 877a so thats never been an issue.

    If anyone has any ideas or suggestions they are appreciated.
    David

  2. #2
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Did you read out

    Hi,

    Did you try to read out the program memory from the faulty pic? How do you know you really had a problem? Do you have brown out turned on or off?

    Sometimes if BOR is off and the pic gets crazy pulling the plug on it might not be enought to reset it properly if BOR is turned off. The pic will continue runing on the charge in caps and power adapters. Pulling MCLR to GND will help :-)

    Also make sure low voltage programming is turned off or if you use that function make sure that pin is controlled properly ( if 877A has that feature)

    AND make sure you program is set up properly for the 877A. You can not run the same program on a 877 as an 877A without getting problems :-)

    One time is a freak accident.... 2 times is a bad habit

  3. #3
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jumper View Post
    Hi,

    Did you try to read out the program memory from the faulty pic? How do you know you really had a problem? Do you have brown out turned on or off?

    Sometimes if BOR is off and the pic gets crazy pulling the plug on it might not be enought to reset it properly if BOR is turned off. The pic will continue runing on the charge in caps and power adapters. Pulling MCLR to GND will help :-)

    Also make sure low voltage programming is turned off or if you use that function make sure that pin is controlled properly ( if 877A has that feature)

    AND make sure you program is set up properly for the 877A. You can not run the same program on a 877 as an 877A without getting problems :-)

    One time is a freak accident.... 2 times is a bad habit
    '16F877A specifics and Defines
    @ DEVICE pic16F877A, HS_OSC ' System Clock Options
    @ DEVICE pic16F877A, WDT_ON ' Watchdog Timer
    @ DEVICE pic16F877A, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F877A, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F877A, LVP_ON ' Low-Voltage Programming
    @ DEVICE pic16F877A, CPD_OFF ' Data Memory Code Protect

    That board has a reset on it and the first thing I did was a simple reset and that did nothing. I unplugged it and left it unplugged for a minute or two then plugged it back in and still got nothing. I hplugged the RS232 in because I did have my program outputting some stats and I got nothing. So after trying reset a few more times and unplugging it a couple of times thats when I decided to load the program back on it. I did try and do a download but I have to be honest I had no idea if it downloaded the same program or not. Winpic indicated it was donwloading something and there was garbage in the HEX window but I've no way of knowing if it was garbage or was the original program I loaded, I did not save it. I uploaded my program again and it just went back to working like before.

    I am making sure I have the correct codes for the 877a I've never hd a problem before and the programmer I have won't program this unless LVP is on. I am wondering now what "Data Memory Code Protect" is perhaps that should be on. This is the first time I have every had a problem like this with these pic's.
    Thanks
    David

  4. #4


    Did you find this post helpful? Yes | No

    Default

    I've seen eproms program correctly, and then verify without fault...
    But as soon as you take them out of the programmer they loose their contents like ram...
    Turns out it was a faulty batch...

  5. #5
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by comwarrior View Post
    I've seen eproms program correctly, and then verify without fault...
    But as soon as you take them out of the programmer they loose their contents like ram...
    Turns out it was a faulty batch...
    The thing about this is that it's been running non-stop without incident for a couple of months so I doubt this was a bad batch. I'm thinking it might have had something to do the storm and the close proximity lightning strike we had or perhaps the fact that most of the pins are left hanging tied to nothing. Maybe there was a build up or something.

    Thanks
    David

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I've seen that happen several times.
    Most of my stuff is on Yachts and Oil rigs, so they take a lot of lightning strikes.

    Occasionally, a few bit's in both Flash (program memory) and/or EEPROM will get erased (to a 1). Not whole bytes, just random individual bits. Depending on which bits get erased, almost any problem imaginable can happen. Sometimes only one function doesn't work right anymore, other times it's just dead, locked up in a loop somewhere. Sometimes other components are black and crispy, other times all components are fine and only the memory got changed.

    Too bad you didn't save the download, a comparison with the original hex could have confirmed the hypothesis.

    I originally started out with Basic Stamps, which were a lot worse than PIC's. Their program corrupts if a butterfly farts nearby. And lightning usually takes them out completely.

    The PIC's were always fine, just reload and go.

    I've tried all kinds of MOV's, and Transient suppressors, and gas discharge tubes, but it still happens. Since a nearby strike normally enters through the "ground" on a boat, there's nowhere to shunt it to. So I stopped using them all together, because they create problems of their own as well.

    It's amazing that the lightning strike seems to affect the boat captains memory too. It's not till he finds out that there won't be any repair cost, that he suddenly remembers, oh yeah, it must have been that lightning strike we took. (lightning damage isn't covered by the warranty).
    <br>
    DT

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,955


    Did you find this post helpful? Yes | No

    Default

    Darrel, do you have your devices in metal enclosures?

    I had similar effects on devices placed in the car parkings and were exposed in the open. But were built in plastics...

    I wonder why the other electronics on-board still work, or not?

    Ioannis

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Nope, they're in a NEMA4 PVC enclosure, although that enclosure is inside a metal frame.

    And when they do fess up, I've heard that Radar and navigation were knocked out too, but the radio's still work fine. (but who knows for sure)
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    I have had similar problems in machine shops around welders
    and plasma cutters. A metal enclosure with a good earth ground
    normally helps. Have to add another ground rod a lot of times.

    How do you earth ground a boat?
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    ...

    How do you earth ground a boat?
    You wire a long cable to the shore

    If you can't find one long enough, use a wireless hub to make it. Everything goes wireless these days.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by mackrackit View Post
    How do you earth ground a boat?
    Hi, Dave

    No Problem ... Darrel's boat always stay along its Wharf ... Web Terminals do not work past the Harbour !!!


    You also could use the anchor ...

    BTW ... I thought sea water was conductive ... isn't it ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    How do you earth ground a boat?
    Boats usually have Zinc electrolysis plates on their bottoms to which all metal is grounded.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  13. #13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    How do you earth ground a boat?
    run it up onto the beach...

    Sorry, couldn't resist...

    Seawater is conductive (depending on voltage) but also very corrosive...
    i think their is a metal (possibly zinc) strip to the bottom of a boats keel...

    As for using the anchor, you can't... corrosion on each individual chain loop will cause insulation...

    The fun comes when you try to figure out how to earth a plane...

  14. #14
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,955


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by comwarrior View Post
    The fun comes when you try to figure out how to earth a plane...
    Hmm, and why should you? It is floating isn't it??

    Ioannis

  15. #15


    Did you find this post helpful? Yes | No

    Default

    lightning will still strike a plane...

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


    Did you find this post helpful? Yes | No

    Default

    Yes, but theoretically shouldn't do any damage as the aircraft is itself 'floating' and not connected to a 0v 'Ground'. The engines, chassis and all metal surfaces are bonded together along with busses to provide a local electrical return path. Composites (such as Carbon Fibres) usually (though not always) have an integral mesh or carrier strip which is bonded to the vehicle 'ground'. In flight it could be quite common for an aircraft to be charged at quite a high potential - so it's 'ground' is not at 0v, but some arbitrary 'floating' (pun intended) value.

    You could connect a PICs Vdd to several hundred kV (and happilly run it) - providing Vss is never more than say five volts lower than Vdd... I have an application for a domestic boiler Gas Ignition board using a PIC where Vdd is actially 0v (Ground) and Vss is -5v (it's easier then to use Comparators to detect if you have a flame as it creates negative ions). You can mess things around quite happilly providing you stay overall within the Datasheet parameters.

  17. #17
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Have you forgotten the Faraday cage principle?

    Al.
    All progress began with an idea

  18. #18
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default

    Thanks everyone for your input. It appears this lightning strike was the cuplrit. If I ever see this again I plan on saving the downloaded code to see how much it actually deviates from the original source.

    Appreciate everyones time on this.

    David

  19. #19
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Melanie View Post
    Yes, but theoretically shouldn't do any damage as the aircraft is itself 'floating' and not connected to a 0v 'Ground'. .
    Hi, Mel

    Only theoretically ...

    Ten years ago thunder striked my house ...

    and I got damaged electronics aboard one of my model planes : a receiver and two servo amps were damaged.

    the model ( wood built ) was hung to a metal tube ( connected to ground ) of the central heating by a piece of string ...

    so it was really " floating " ...

    I do think cables act like a transformer secondary if lightning passes closer enough ! a good magnetic shielding of the enclosure looks necessary too ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  20. #20
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,955


    Did you find this post helpful? Yes | No

    Default

    Alain, were you inside the house when the thunder stroke?

    Ioannis

  21. #21
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    Alain, were you inside the house when the thunder stroke?

    Ioannis
    I will do my best guess:

    I guess he was outside his home trying to test his hand made volt meter to see whether he could take a reading from the lightning or not.
    (and If so, to see what the deviation could be)

    Am I close?
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  22. #22
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Ioannis View Post
    Alain, were you inside the house when the thunder stroke?

    Ioannis
    Hi, Ioannis

    I quietly was sleeping in my bed ... and was awaken by an unusual "bang".

    Thunder striked in my wife's father room ... making a nice hole in the plaster of the wall, to reach the grounded central heating tubing.

    Of course there was plaster powder spread everywhere !!! ... somewhat funny. my father in law appearance was funny too ...

    I saw for the first time what happens to transformer windings : every turn is cut into two parts and thrown everywhere... astonishing !

    Also Noted Aluminium shielded TV cable takes fire ( dangerous ! ) ... but not Copper shielded one !

    My scope ( plug was not connected ) trace also was disturbed for seveal month ... not to say more than a year ... ( Trace rotation : 3-4 ° + small sine for Grounded input instead of the line )

    Neibours told me they had seen the Fireball come to the house ... had like to see it too !!!



    Hi, Sayzer

    you're totally out on this one ... I was experimenting with Mel's Leyden Jars !!!

    I wonder was to try your wonderful Turkish invention ( remember : a 12 kW laser to make a solar Windmill rotate ... video + distinguished professor interview provided ...)

    ROFL

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  23. #23
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,955


    Did you find this post helpful? Yes | No

    Default

    Amazing how you make it out of it.

    I am sure neighbours had an impressive show. I don't know about you though!

    Have you thought of installing an lightning arrestor? People think that the thunder will not strike twice but I 've heard otherwise very often.

    Ioannis

  24. #24
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,617


    Did you find this post helpful? Yes | No

    Wink Zeus secrets ...

    Hi, Ioannis

    a Thunder Arrestor is a soltion for High buildings, Castles, Churches ... I always heard a couple of Birch trees make it well ... If no mains lines around.

    Now, Thunder is like water: you can channel them, but never stop them ...

    Why wouldn't thunder strike twice at the same place ??? ... if everything rebuilt as it was ... no reason !!!

    But as clouds are randomly placed and constituted ... difficult to get twice the same HV Generator characteristics !!!

    Regards
    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Serial VB 2005 pic 16f877a problems
    By Snap in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 8th July 2013, 00:52
  2. help my bluetooth and PIC 16F877A?
    By slimpeng in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th March 2008, 06:52
  3. Two PIC 16F877A fried in two days!
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th January 2007, 10:38
  4. Memory Loss??
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th October 2006, 11:10
  5. Matching PIC memory and program size?
    By manxman in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th August 2006, 08:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts