Using MQX LPM on K22 (MQX 4.2)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using MQX LPM on K22 (MQX 4.2)

604 Views
ebollerman
Contributor I

Hey All,

I have a question regarding the use of the LPM on the K22, specifically switching back and forth between LPM_OPERATION_MODE_RUN and LPM_OPERATION_MODE_WAIT. I am brand new to this so pardon any ignorance. My chip seems to be resetting after going back into LPM_OPERATION_MODE_RUN mode. I have enabled MQX_ENABLE_LOW_POWER in user_config.h and am able to successfully switch to WAIT mode. Once I am in wait mode however, I am reset and my debugger show that I am in boot.S and restarting. I have used the low power example and the flow of my program is quite simple and is similar to this:

if (CM_ERR_OK != _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_2MHZ))
{
_task_block();
}
_lpm_set_operation_mode (LPM_OPERATION_MODE_WAIT);

/* wait for button press */

_lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);
if (CM_ERR_OK != _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_DEFAULT))
{
_task_block();
}

My problem seems to occur inside _lpm_clock_configuration() -> _cm_set_clock_configuration() -> _bsp_set_clock_configuration()

Sorry if this is too broad. Any help, or understanding of how the LPM actually works would be greatly appreciated!

Thanks

0 Kudos
2 Replies

413 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Eric Bollerman

From WAIT mode (mapped to VLPR mode) to Run mode, I would suggest you set clock configuration first, next set operation mode.

From your code, it seems you set operation mode first.

_lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);
if (CM_ERR_OK != _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_DEFAULT))
{
_task_block();
}

Could you try to double check it?

Here is a document about MQX Low-Power Management, it describes how it works and how to use it.

http://cache.nxp.com/assets/documents/data/en/application-notes/AN4447.pdf?fsrch=1&sr=1&pageNum=1 

I hope it helps.

Regards

Daniel

--------------------------------------------------------------------------------

Please click correct or helpful button if this post is helpful, thank you

-----------------------------------------------------------------------------------

0 Kudos

413 Views
ebollerman
Contributor I

Hi Daniel,

Thank you for your response, and thank you for the advice. I reversed the order of the code as suggested and found different behavior. Instead of restarting the chip it gets caught at the line below inside of Cpu_SetMCGModeFBE() and case 0:

   while((MCG_S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */

   }

Is there any action I need to take here in setting MCG_S or I am just missing something?

Thanks,

Eric

0 Kudos