MQX LPM on K60
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
has anyone experience in using the LowPowerManagement of MQX on the K60? I have problems registering the drivers in the LPM. Can anyone give me an example how to register the serial driver for the LPM?
Thanks,
Tobias

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The serial driver should already be registered in the BSP (if you updated the driver to the new drivers included with 3.8/3.8.1) But to do it for your own stuff is pretty straighforward as you can see in the code I've attached
So a couple items to keep in mind though:
- The dependency level is used by the LPM to decide the order in which the callbacks are called during each mode transition - so if you have multiple registered items that have a specific order you'll have to make sure you set the dependancy level correctly
- Tasks that are accessing hardware that you will be turning off during sleep need to be stopped from accessing said hardware or else they may end up in undesired states. For example a task acessing the serial port when the module goes to sleep likely will be in a permanent blocks state. Thus it is my recommendation to stop the task prior to attempting to change mode to sleep or stop (waiting for an event, checking a flag you set, etc)
- If you are using a low power run mode where the clocks are modified there is a heck of lot more work to do - the lpm example included with mqx does a good job of going over what all you need to do (but I'm sure it is quite hardware dependent as well) "C:\Program Files\Freescale\Freescale MQX 3.8\mqx\examples\lowpower"
static uint_32 mainLpmRegHandle; static LPM_NOTIFICATION_RESULT mainLpmCallback(LPM_NOTIFICATION_STRUCT_PTR notification, pointer data ) { if (LPM_NOTIFICATION_TYPE_PRE == notification->NOTIFICATION_TYPE) { if(notification->OPERATION_MODE == LPM_OPERATION_MODE_RUN) { /* Do wakeup stuff - like sending wake-up events to sleeping tasks */ } else if( notification->OPERATION_MODE == LPM_OPERATION_MODE_STOP || notification->OPERATION_MODE == LPM_OPERATION_MODE_SLEEP) { /* By this point tasks that are working with hardware should have been stopped manually and this will now turn off power sources to hardware */ #ifdef ENABLE_WATCHDOG _watchdog_stop(); #endif } } return LPM_NOTIFICATION_RESULT_OK; }
void main_task(uint_32 initial_data) {
// ...
#if MQX_ENABLE_LOW_POWER { LPM_REGISTRATION_STRUCT registration; registration.CLOCK_CONFIGURATION_CALLBACK = NULL; registration.OPERATION_MODE_CALLBACK = mainLpmCallback; registration.DEPENDENCY_LEVEL = 29; _lpm_register_driver (®istration, NULL, &mainLpmRegHandle); } #endif
// ... /* Sleep */ _lpm_set_operation_mode (LPM_OPERATION_MODE_STOP); //Or _lpm_set_operation_mode(LPM_OPERATION_MODE_SLEEP); /* Run */ _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);
// ...
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Tobias,
what particular problems are you copying with? What have you done so far, share some code snippets,provide more info.
Regards,
MartinK
