Hi SCOTT MILLER,
Thank you very much for your more question details and the patience to explain it.
I am really very sorry for the confuse which I bring you with my inaccurate statements, but I really don't mean any offense to you, all I wanted was to help you get out of this problem and get more question information which is useful to the problem solution.
Now, you already give me enough information:KSDK 1.3, WAIT low power mode, MK02FN64VLF10, POWER_SYS_SetMode(1, kPowerManagerPolicyAgreement);
Answer your 2 questions:
1. Debugger lost when enter WAIT mode
If you use the POWER_SYS_SetMode(1, kPowerManagerPolicyAgreement); to enter in the WAIT mode, actually, just like what I have said, WAIT mode won't disconnect the debugger, except you disable the SWD interface with code.
When you do step debugging in POWER_SYS_SetMode, did you meet this code:
disable_unused_pins();

void disable_unused_pins(void)
{
/* Disable debug pins when MCU sleeps */
setup_debug_pins(kPortPinDisabled);
/* Disable uart pins */
setup_uart_pins(kPortPinDisabled);
}
}
If yes, please comment it, this code is used to disable the SWD debug interface and the uart interface.
I already check it with the KSDK1.3.0 sample code with our FRDMK22:C:\Freescale\KSDK_1.3.0\examples\frdmk22f\demo_apps\power_manager_hal_demo
After I comment code disable_unused_pins();, even I enter in the WAIT mode with debugger, the debugger still can be connected, and after the WAIT mode is wakeup, the debugger can enter in the RUN mode again.
2.The most efficient WAIT mode entry procedure
Yes, you are correct, the KSDK code is really long, complicate.
If you want to enter in the WAIT mode, actually, you don't need to call all that functions, the KSDK is the full function for all the low power code.
You can write your own simplified code.
Take an example:
void enter_wait()
{
volatile uint32_t dummyRead;
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
/*
* Ensure that all register writes associated with setting up the
* low power mode being entered have completed before the MCU enters
* the low power mode.
*/
dummyRead = SMC_RD_PMCTRL(SMC);
dummyRead = dummyRead;
__WFI();
}
Then just call enter_wait() instead of POWER_SYS_SetMode(1, kPowerManagerPolicyAgreement);
Please use my code and try again!
If you still have question, please contact with me!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------