+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 4
    Points: 99, Level: 1

    Join Date
    Oct 2018
    Posts
    7
    Helped
    0 / 0
    Points
    99
    Level
    1

    Random execution of code after a reset.

    Hi All,

    I think All strange problems are with me...:P:(

    After the code is flashed On first power On, the code works fine...

    And I start executing some part code by external USART Messages which ends up with an intentional WDGT reset..

    Once reset happens...

    Code starts behaving in weird manner...

    The Execution directly starts executing the "DoSomething" in default without even calling the function....

    This is how the Template code is

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    void SomeFunction(void)
    {
      Switch( Variable )
      {
          case 1:
               Do Something;
               break;
          case 2:
               Do Something:
               break;
          default:
                Dosomething;
                break;
        }
    }


    How come this could happen...

    Can anyone helpme with this thing??

    •   AltAdvertisment

        
       

  2. #2
    Super Moderator
    Points: 78,154, Level: 68
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,788
    Helped
    4272 / 4272
    Points
    78,154
    Level
    68

    Re: Random execution of code after a reset.

    We would have to see the full code but usually this happens because some variable isn't initialized. A hardware reset and a watchdog reset are not identical, you should refer to the data sheet to see the state of registers after each occurs.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisment

        
       

  3. #3
    Advanced Member level 4
    Points: 7,367, Level: 20

    Join Date
    Jan 2015
    Posts
    1,035
    Helped
    325 / 325
    Points
    7,367
    Level
    20

    Re: Random execution of code after a reset.

    I second the call to see all of the code (or, preferably, a short but complete code example that demonstrates the problem).
    What device?
    Can you explain how you are determining where the code starts after a WDT reset?
    As the code is 'C', I'm certain that there will be code executed as part of the C runtime that sets things up before the 'main' is called. Are you setting a breakpoint in this startup code or just somewhere in your own code?
    Susan



    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 5
    Points: 8,980, Level: 22
    Achievements:
    7 years registered
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,583
    Helped
    362 / 362
    Points
    8,980
    Level
    22

    Re: Random execution of code after a reset.

    PIC and other 8-bit microcontrollers doesn't support core fault vectors, in case of any troubles with pointers they just getting crazy. That's why learning with arms or linux is better for begginers. You can at least understand where you doing something wrong and stop guessing.
    Love me or hate me. All infractions will be ignored.



--[[ ]]--