This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Will a debugger prevent entering Deep Software Standby?

I'm using an RA6M3 connected to IAR's EWARM IDE via a J-Link Ultra+. I've read the Low Power Mode section of the RA6M3 user's manual and have looked at the register values and I think I have everything configured correctly. However, when I single-step through my code, it just steps right over the WFI instruction. I would expect the WFI to never return. The debugger would only resume after the device has reset out from the deep software standby state.

Before I pull out more hair, I thought I'd check to see if it is the debugger itself that is preventing the RA6M3 from entering deep software standby.




[locked by: Sai (SWF) at 12:32 (GMT 0) on 17 Nov 2022]
  • Hi ,

    I'm not exactly sure with the RA6M3 and its debugger, but in RL78, when executing HALT in debug mode, it will just also step right over the HALT instruction. Maybe the debugger doesn't emulate standby functions. I hope someone from this forum can confirm this.

    JB
    If this response, or one provided by another user, answers your question, please verify the answer. Thank you!
    Renesas Engineering Community Moderator
    https://community.renesas.com/
    https://academy.renesas.com/
    https://en-support.renesas.com/knowledgeBase/

  • Have you looked at the app note:

    Getting Started with Low Power Applications Package for RA6M3 and RA4 Groups Application Project (mouser.com)

    In summary, yes the debugger ill not allow you to enter SW Standby mode or Deep Software Standby mode.

    However, if you use the low power debug script as mentioned in the app note, then yes, you can debug through DP SW Stby mode

  • Hi Richard,

    I did not find that app note, but I found the script in another posting. From the script, it appears the key is to clear the DBIRQ bit in the MCUCTRL register (section 2.6.5.3 in the RA6M3 User's Manual). MCUCTRL is only accessible via the debugger, so you can't clear this bit in firmware. The debugger needs to do it.

    I am using EWARM, not E2. I'm not sure if I can use that script directly or not. I'll have to experiment. EWARM does come with a R7FA_DBG.dmac script that clears this bit in _ExecDeviceCoreConnect(), but it isn't happening. I don't know why. I'm still investigating that.

    Has anyone succeeded in debugging the low power modes using EWARM? If so, did you need to do anything special?

  • please have a look at this Synergy low power example.

    I hope this is the correct link


    https://www.renesas.com/us/en/document/scd/low-power-modes-v2-hal-module-guide-application-project-rev102-sample-code?language=en

    This has the IAR .mac file and how to configure the IAR debug session to allow low power debugging 

  • I've done more research and have a solution. Two, actually.

    The script mentioned in the app note cited by Richard can be used. Getting C-Spy (the EWARM debugger) to run the J-Link script involves editing a configuration file. It cannot be done directly from within EWARM.

    EWARM creates a "settings" folder in the project folder. Look for a file(s) that end in .jlink. There should be one for each build configuration you've used in a debug session. Edit this file(s). Look for the ScriptFile="" line and put the name of the script file in the double quotes. Adjust the path as necessary (the default working directory is the "settings" folder). Once done, the script will run when the debugger attaches to the processor and you'll be able to enter low power modes with the debugger attached.

    While workable, I didn't like this solution because the "settings" folder and its contents are automatically generated. I don't track them in my revision control and any changes I make to them might get over-written the next time the files are generated.

    The other solution is to create a macro file containing the following:

    execUserSetup()
    {
        allow_lp_mode();
    }
    
    execUserAttach()
    {
        allow_lp_mode();
    }
    
    allow_lp_mode()
    {
        /*
         * Clear the MCUCTRL.DBIRQ bit.
         * Without this, the MCU will not be able to enter low
         * power modes.  The debugger interrupt will immediately
         * wake the processor and the WFI will look like a nop.
         */
        __writeMemory32(0, 0x80000410, "AP1_Memory");
    }

    Then, from EWARM, go to Options > Debugger > Setup > Setup macro(s). Add the path to this macro file. That's it. Now when you attach the debugger, the MCUCTRL.DBIRQ bit will be cleared and you'll be able to enter the low power modes when you issue the WFI instruction.

    I've also verified that the debugger will reattach after you reset out of Deep Software Standby.