• AVR Freaks

Hot!MCU starts twice on debug build

Author
dlindbergh
Super Member
  • Total Posts : 483
  • Reward points : 0
  • Joined: 2006/09/11 18:17:11
  • Location: Boston USA
  • Status: offline
2019/12/10 17:36:30 (permalink)
0

MCU starts twice on debug build

When I do "Debug Project", my project builds, gets flashed into the MCU, then starts.
 
Oddly, each time it starts twice - it runs for a few milliseconds, then restarts.
 
Is this normal? Is there any way to make it start just once? It's mildly annoying.
 
I'm on:
 
* MPLAB X IDE 5.30
* RealICE
* PIC32MX440
 
The first start I get a code in RCON (reset cause) of 0x81 - that's "EXTR: External Reset (MCLR) Pin Flag bit" and "POR: Power-on Reset Flag bit".
 
The second start (a few milliseconds later) RCON has 0x80 - just the EXTR.
 
(FWIW, the board is not powered by the RealICE - it's got it's own power supply.)
 
Advice?
#1

2 Replies Related Threads

    Mysil
    Super Member
    • Total Posts : 3676
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: MCU starts twice on debug build 2019/12/10 18:37:59 (permalink)
    +2 (2)
    Yes,
    It is that way, I have seen it several times, and sometimes it can have confusing effects.
    After build and programming, the microcontroller start running by itself,
    while the debugger get itself organized, and after a while Reset the chip and take control.
     
    If you push the Icon: 'Hold in Reset', the time running wild is at least reduced. 
    It doesn't affect debugging.
     
        Mysil
    #2
    Jim Nickerson
    User 452
    • Total Posts : 6715
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: MCU starts twice on debug build 2019/12/11 08:08:39 (permalink)
    0
    I have seen similar things.
    The PIC gets the power supply turned on and if it already has been programmed the previous program begins running before the debugger hits MCLR to start the programming sequence.
    In some cases I have added a delay at the beginning of my program to give the debugger a chance to start.
    In other cases I erase the PIC before starting a debug session.
    #3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5