Hello,
I am now facing some issue while trying to implement the wake up after a sleep phase. My need is quite simple, the system needs to sleep and use as low as possible of current, and wake up each X minutes, or upon a switch button pressed.
Si I took inspiration from the power manager rtos demo, but could'nt get the whole thing working.
My behaviour is currently :
- configure the power manager structures, especially :
power_manager_user_config_t const vlls1Config = { .mode = kPowerManagerVlls1, .lowPowerWakeUpOnInterruptValue = kSmcLpwuiEnabled, .sleepOnExitValue = false, };
In the init :
void Init_Task(task_param_t init_data) { _task_id t_id; power_manager_error_code_t ret; osa_status_t osa_ret; osa_ret = OSA_Init(); if(osa_ret != kStatus_OSA_Success) { PRINTF("OSA_Init failed\n"); } Gpio_Init(); // initialize power manager driver POWER_SYS_Init(powerConfigs, powerConfigsSize, pm_callback_tbl, pm_callback_tbl_size); ret = POWER_SYS_SetMode(0, kPowerManagerPolicyAgreement); // 0 = index of powerConfigs osa_ret = OSA_Start(); [..]
And then I call a shell function "stop" :
int32_t Shell_stop(int32_t a, char *argv[]) { power_manager_error_code_t ret; // Wake up on SW1 - enables falling edge interrupt for switch SWx PORT_HAL_SetPinIntMode(BOARD_SW_LLWU_BASE, BOARD_SW_LLWU_PIN, kPortIntFallingEdge); OSA_InstallIntHandler(LLWU_IRQn, MQX_LLWU_IRQHandler); INT_SYS_EnableIRQ(LLWU_IRQn); NVIC_SetPriority(LLWU_IRQn, 6U); LLWU_HAL_ClearExternalPinWakeupFlag(LLWU_BASE_PTR, (llwu_wakeup_pin_t)BOARD_SW_LLWU_EXT_PIN); LLWU_HAL_SetExternalInputPinMode(LLWU_BASE_PTR,kLlwuExternalPinFallingEdge, (llwu_wakeup_pin_t)BOARD_SW_LLWU_EXT_PIN); ret = POWER_SYS_SetMode(1, kPowerManagerPolicyAgreement); // 1 = index de powerConfigs if (ret != kPowerManagerSuccess) { PRINTF("POWER_SYS_SetMode(1) returned unexpected status : %u\n\r", ret); return 1; } return 0; }
I am supposing the ISR function that should be called is one of those :
/* IRQ handler for switch/button. */ void BOARD_SW_LLWU_IRQ_HANDLER(void) { PORT_HAL_ClearPortIntFlag(BOARD_SW_LLWU_BASE); } /* LLW_IRQHandler that would cover the same name's APIs in startup code */ void MQX_LLWU_IRQHandler(void) { // The LLWU wakeup interrup is Switch/Button source if (LLWU_HAL_GetExternalPinWakeupFlag(LLWU_BASE_PTR,(llwu_wakeup_pin_t)BOARD_SW_LLWU_EXT_PIN)) { LLWU_HAL_ClearExternalPinWakeupFlag(LLWU_BASE_PTR, (llwu_wakeup_pin_t)BOARD_SW_LLWU_EXT_PIN); } } void LLWU_IRQHandler(void) { LLWU_HAL_ClearExternalPinWakeupFlag(LLWU_BASE_PTR, (llwu_wakeup_pin_t)BOARD_SW_LLWU_EXT_PIN); }
What is curious is, when I am executing this software, and calling the stop function, then everything stops (no led blinking etc), so it seems to be effectively in vlls1. But when I push the button, the boards wakes up and I get the debugger (KDS + PE Multilink) saying : __isr_vector() at 0x00, instead of some line of a standard reset flow. What is also curious is, my board actually reboots and I get the correct reset flow (init + shell) but there is some reboot during this reset flow, so I am actually getting this on the uart :
**************************************************************** Init of system... init i2c ok Flash Information: Exec from Blocks 0/1 Flash is UNSECURE! task gpio created. task main created. Starting HTTP server No.0 on IP 192.168.1.202, port 80...[OK] Shell (build: Sep 2 2015) Copyright (c) 2013-2014 Freescale Semiconductor; shell> shell> shell> stop **************************************************************** Init of system... init i2c ok Flash Information: Exec from Blocks 0/1 Flash is UNSECURE! task gpio created. task main created. **************************************************************** Init of system... init i2c ok Flash Information: Exec from Blocks 0/1 Flash is UNSECURE! task gpio created. task main created. Starting HTTP server No.0 on IP 192.168.1.202, port 80...[OK] Shell (build: Sep 2 2015) Copyright (c) 2013-2014 Freescale Semiconductor; shell> shell>
So I think I am missing some tiny little thing about the LLWU interrupts, some misconfiguration, but apparently the wake up seems ok, it's just the jump from wakeup to isr_vector that I cannot explain.
Other point, if I don't use a debugger, then I cannot get a wake up after the sleep. The systems seems to get lost during the wake up, before any init (no output on uart).
So how could I debug this ? Do you know how I could check (by debug or printf) if my config is ok, adress of isr, or anything before going in sleep ?
Thanks for you help
Samuel
Solved! Go to Solution.
issue solved, another post gave me the clue, a line missing in my hardware init.
issue solved, another post gave me the clue, a line missing in my hardware init.
Thank you very much for sharing your comments Samuel,
Hopefully you could share the post where you found the answer, so other people who have the same problem as you can reach the solution.
Best regards!
Carlos
Well, it's easier to paste the missing lines, that find this post :-)
in hardware_init, thoes lines are mandatory :
if(PMC_HAL_GetAckIsolation(PMC_BASE_PTR) != 0)
{
PMC_HAL_ClearAckIsolation(PMC_BASE_PTR);
}
regards