MQX Low Power Mode: stop from wait

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

MQX Low Power Mode: stop from wait

1,381 Views
Curro
Contributor III

Good evening,

I'm working on a K60 MQX3.8, I need ethernet, but in some conditions I need to go to LPM_OPERATION_MODE_STOP.

For a stable Ethernet RMII PHY working I needs a 50MHz ext clock source that I even use for cpu.

I need to disable oscillator (enable pin) before going to LPM_OPERATION_MODE_STOP.

To do this I tried this sequence but it doesn't go.

1. LPM_OPERATION_MODE_RUN -> LPM_OPERATION_MODE_WAIT (switch to intenal oscillator)

2. switch off oscillator with a GPIO port

3. LPM_OPERATION_MODE_WAIT -> LPM_OPERATION_MODE_STOP

4. reverse operations to wahe up

With this code everything is OK (tested with oscilloscope).

I go in and out wait condition and switch off/on ext oscillator

    MCG_C6 &= ~MCG_C6_CME_MASK;

    _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_2MHZ);

    _lpm_set_operation_mode (LPM_OPERATION_MODE_WAIT);

    _time_delay(1000);

    SetGen(Osc,OFF);//switch off oscillator

    _time_delay(1000);

    SetGen(Osc,ON);

    _time_delay(1000);

    _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);

    _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_DEFAULT);

    MCG_C6 |= MCG_C6_CME_MASK;

Even this code is OK:

    MCG_C6 &= ~MCG_C6_CME_MASK;

    _lpt_run (0, TRUE);//timer start

    _lpm_set_operation_mode (LPM_OPERATION_MODE_STOP);

    _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);

    MCG_C6 |= MCG_C6_CME_MASK;


The problem is when I go to STOP from WAIT. I never wake up from LPM_OPERATION_MODE_STOP even if I keep ext osc on.

    MCG_C6 &= ~MCG_C6_CME_MASK;

    _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_2MHZ);

    _lpm_set_operation_mode (LPM_OPERATION_MODE_WAIT);

    _time_delay(1000);

    _lpt_run (0, TRUE);

    _lpm_set_operation_mode (LPM_OPERATION_MODE_STOP); <<<----------- code stops here!!!

    _lpm_set_operation_mode (LPM_OPERATION_MODE_WAIT);

    _time_delay(1000);

    _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);

    _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_DEFAULT);

    MCG_C6 |= MCG_C6_CME_MASK;

Any idea?

Thank you,

Corrado

0 Kudos
Reply
2 Replies

675 Views
DavidS
NXP Employee
NXP Employee

Hi Corrado,

The LPM operation mode WAIT equates to Kinetis CPU power mode of VLPR (the clock is the internal fast clock [2 or 4MHz depending on revision of silicon]).  When in WAIT/VLPR mode you can transition into the LPM operation mode STOP (equates to Kinetis CPU power mode of LLS).  But when the LLWU wants to wake up the Kinetis device from STOP/LLS mode, it will go directly into the LPM operation mode RUN (equates to the Kinetis CPU power mode of RUN).  So when you get into the RUN/RUN mode you should be able to skip the _lpm_set_operation_mode (LPM_OPERATION_MODE_WAIT); step.

I used the K60 RM Mode Controller Figure Power Mode State Diagram.  It seems to indicate that you cannot go from the Kinetis LLS back to VLPR mode (but I did also see a statement that said LLS would return to whatever mode it came from....so the docs not totally black&white on this topic).

Have you tried just going from RUN/RUN directly into STOP/LLS mode?

Regards,

David

675 Views
Curro
Contributor III

Hi David,

I think you are in right when you say "when the LLWU wants to wake up the Kinetis device from STOP/LLS mode, it will go directly into the LPM operation mode RUN". In Figure 7-1. Power mode state transition diagram of reference manual, in Power mode transitions chapter, it is shown you can enter in LLS mode both from VLPR and RUN but you exit only to RUN mode.

Yes, I tried to go from RUN directly into STOP/LLS mode and reverse and all runs perfect.

However my goal is to set a GPIO just before going in STOP mode and clear it just before coming back to RUN (switch off through enable pin external 50MHz oscillator to cut down current supply).

I also tried to solve my problem by switching cpu to internal clock.

My idea was:

1. switch to 2MHz internal clock

2. set GPIO (ext osc disable)

3. STOP mode

4. interrupt wakes cpu in RUN mode, internal clock

5. clear GPIO (ext osc enable)

6. switch to RUN ext 50MHz clock

If I perform points 1,2,5,6 it's all ok (tested with oscilloscope).

If I just perform points 1 and 3 (even keeping ext osc on), cpu doesn't performs point 4 and crashes.


Finally, do you think I can go in STOP mode from a RUN 2MHz state?

If yes, cpu still comes out from STOP in the same RUN 2MHz state?

Do you have any other good idea to solve my problem?

Many thank,

Ciao

Corrado

0 Kudos
Reply