Hi, I'm using kl27z256 with KDS3.0.0, and KSDK 1.2.0, and must use deep sleep mode. I want to know the correctly way to disable and reenable the modules/components in my project with PEx, this is necessary to drop current consumption. This is what i'm trying:
-VLPS mode (very low power mode) to deep sleep, Configured with callbacks before and after.
this working fine,but the current is around 14mA,
disabling the components used in project, the current consumption is 100uA.
//before sleep
power_manager_error_code_t pwrMan1_StaticCallback0(power_manager_notify_struct_t * notify, power_manager_callback_data_t * dataPtr)
{
power_manager_error_code_t status = kPowerManagerSuccess;
UART_DRV_Deinit(FSL_UART);
USB_Class_HID_Deinit(hid1_HidHandle);
PIT_DRV_Deinit(FSL_PIT);
SPI_DRV_MasterDeinit(FSL_SPI);
SPI_DRV_MasterDeinit(FSL_SPI_ADS);
ADC16_DRV_Deinit(FSL_ADC);
return status;
}
//after sleep
power_manager_error_code_t pwrMan1_StaticCallback1(power_manager_notify_struct_t * notify, power_manager_callback_data_t * dataPtr)
{
power_manager_error_code_t status = kPowerManagerSuccess;
LPTMR_DRV_Stop(FSL_LPTMR1); //stop timer
PE_low_level_init();
return status;
}
But when returning from VLPS, the UART module don't works,
note the use of the PE_low_level_init() to reenable the components.
Is this correct?
已解决! 转到解答。
Hello Rafael,
I would recommend you to enable each module manually instead of calling PE_low_level_init function (UART_DRV_Init, PIT_DRV_Init, etc), besides, in reference to power_manager_hal_demo_frdmkl27z example (C:\Freescale\KSDK_1.2.0\examples\frdmkl27z\demo_apps\power_manager_hal_demo), power mode callback is disabling pins for default console (in this case, LPUART0 module) and debug port when entering VLPS:
case kPowerManagerNotifyBefore:
userData->before.counter++;
do
{
isLastByteTranmistComplete = LPUART_HAL_GetStatusFlag(BOARD_DEBUG_UART_BASEADDR,kLpuartTxComplete);
} while (!isLastByteTranmistComplete);
disable_unused_pins();
ret = kPowerManagerSuccess;
and disable_unused_pins is defined as follows:
void disable_unused_pins(void)
{
/* Disable debug pins when MCU sleeps */
setup_debug_pins(kPortMuxAlt4);
/* Disable uart pins */
setup_uart_pins(kPortPinDisabled);
}
same callback is enabling pins when MCU has wake up from VLPS:
case kPowerManagerNotifyAfter:
userData->after.counter++;
enable_unused_pins();
ret = kPowerManagerSuccess;
break;
void enable_unused_pins(void)
{
/* Enable debug pins when MCU sleeps */
setup_debug_pins(kPortMuxAlt7);
/* Eable uart pins */
setup_uart_pins(kPortMuxAlt2);
}
These functions should be defined manually and they only configure respective PORTx_PCRn register for each pin used.
In summary, besides disabling/enabling each module, it is necessary to disable/enable each used pin for UART module.
Hope this can help,
Regards,
Isaac
Hello Rafael,
I would recommend you to enable each module manually instead of calling PE_low_level_init function (UART_DRV_Init, PIT_DRV_Init, etc), besides, in reference to power_manager_hal_demo_frdmkl27z example (C:\Freescale\KSDK_1.2.0\examples\frdmkl27z\demo_apps\power_manager_hal_demo), power mode callback is disabling pins for default console (in this case, LPUART0 module) and debug port when entering VLPS:
case kPowerManagerNotifyBefore:
userData->before.counter++;
do
{
isLastByteTranmistComplete = LPUART_HAL_GetStatusFlag(BOARD_DEBUG_UART_BASEADDR,kLpuartTxComplete);
} while (!isLastByteTranmistComplete);
disable_unused_pins();
ret = kPowerManagerSuccess;
and disable_unused_pins is defined as follows:
void disable_unused_pins(void)
{
/* Disable debug pins when MCU sleeps */
setup_debug_pins(kPortMuxAlt4);
/* Disable uart pins */
setup_uart_pins(kPortPinDisabled);
}
same callback is enabling pins when MCU has wake up from VLPS:
case kPowerManagerNotifyAfter:
userData->after.counter++;
enable_unused_pins();
ret = kPowerManagerSuccess;
break;
void enable_unused_pins(void)
{
/* Enable debug pins when MCU sleeps */
setup_debug_pins(kPortMuxAlt7);
/* Eable uart pins */
setup_uart_pins(kPortMuxAlt2);
}
These functions should be defined manually and they only configure respective PORTx_PCRn register for each pin used.
In summary, besides disabling/enabling each module, it is necessary to disable/enable each used pin for UART module.
Hope this can help,
Regards,
Isaac
Only for Complementary answer,
My problem was solved by disabling some unused pins.
These two lines of code solved:
deinit_uart_pins(FSL_UART);
deinit_spi_pins(FSL_SPI_ADS);
after disabling the components, it is necessary to disable the pins used by them, as isaacavila mentioned.
Complete code:
//before sleep
power_manager_error_code_t pwrMan1_StaticCallback0(power_manager_notify_struct_t * notify, power_manager_callback_data_t * dataPtr)
{
power_manager_error_code_t status = kPowerManagerSuccess;
UART_DRV_Deinit(FSL_UART);
deinit_uart_pins(FSL_UART);
USB_Class_HID_Deinit(hid1_HidHandle);
PIT_DRV_Deinit(FSL_PIT);
SPI_DRV_MasterDeinit(FSL_SPI);
deinit_spi_pins(FSL_SPI);
SPI_DRV_MasterDeinit(FSL_SPI_ADS);
deinit_spi_pins(FSL_SPI_ADS);
ADC16_DRV_Deinit(FSL_ADC);
return status;
}