LLS and wake up with LLWU

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

LLS and wake up with LLWU

2,146 Views
matteopirro
Contributor I

Hello,

I'm trying to use an external pin to wake up my KL15Z4 from LLS using LLWU.

First of all I configure LLWU module.

/* Clear flags for external sources */
dev->regMap->F1 |= 0xFF;
dev->regMap->F2 |= 0xFF;

/* Disable all external sources*/
dev->regMap->PE1 &= 0;
dev->regMap->PE2 &= 0;
dev->regMap->PE3 &= 0;
dev->regMap->PE4 &= 0;

/* Disable all internal sources */
dev->regMap->ME &= 0;

// suppose the pin is in the first PE register

dev->regMap->PE1 &= ~(0b11 << pin*2);
dev->regMap->PE1 |= (event << pin*2);
dev->regMap->F1 |= (1 << pin*2);

NVIC_ICPR = 1 << 7 //LLWU interrupt

NVIC_ISER = 1 << 7; //LLWU interrupt

And then I put the MCU in LLS state.

The debugger disconnects and I am not able to wake up the system with the external pin I configured.

 

I don't have any instruments to understand where I'm wrong. Could you help me?

Consider I'm able to put the MCU in stop and to get it back in run mode using an external interrupt.

Do you need other part of my code?

Thank you

Labels (1)
0 Kudos
Reply
6 Replies

1,405 Views
mjbcswitzerland
Specialist V

Hi

Low Power modes (All K, KL, KV, etc. parts):
http://www.utasker.com/kinetis/LLWU.html
https://www.youtube.com/watch?v=kWNlsAoMly4&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q
https://www.youtube.com/watch?v=v4UnfcDiaE4&index=7&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q

Open Source solution: http://www.utasker.com/forum/index.php?topic=1721.msg7086#msg7086

Tips to external pins:
- some GPIO are disabled by default and must first be configured to their GPIO mode otherwise they will also not operate as wake up sources.
- Example of registers when set up for LLWU interrupt on PTC3 (LLWU_P7)
LLWU_F1 = 0x80; // reset potential pending interrupt
fnEnterInterrupt(irq_LL_wakeup_ID, int_priority, _wakeup_isr); // enter interrupt handler (the handler will be called after the wake up and should be used to clear the interrupt source and anything application-specific)
LLWU_PE2 = 0x80; // set/enable the type required

Regards

Mark

Professional support for Kinetis: http://www.utasker.com/index.html
Remote desktop one-on-one coaching: http://www.utasker.com/services.html
Getting started to expert videos: https://www.youtube.com/results?search_query=utasker+shorts

0 Kudos
Reply

1,405 Views
matteopirro
Contributor I

Thank you,

But I can't use utasker for MCU management. Not in this project. Don't you have an example code for KL15? Or maybe you can tell me which mistake I made in my code.

Matteo

0 Kudos
Reply

1,405 Views
mjbcswitzerland
Specialist V

Matteo

KL15 and KL25 code are the same and all LLWU code is in the file "kinetis_LLWU.h".

As I mentioned - check that you have the GPIO set up as GPIO and not disabled, since some pins on the KL15 default to this and then nothing can work.

It is not possible to work with the debugger in LLS mode so don't try - it disconnects when you enter the mode.

After wake-up make sure that you are handling the interrupt or else the code may get stuck in the LLWU interrupt handler. That means you may wake but your code may lock up.

I am interested in what you mean by MCU management?

The uTasker project is a complete solution to the KL parts which also completely solves low power management. It avoids project difficulties, allow simulation and reduces project development times. Why are proven, working solutions forbidden in some projects?

If you require code fixing you can request the service at http://www.utasker.com/index.html

Regards

Mark

0 Kudos
Reply

1,405 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Matteo Pirro,

    About the LLS wake up code, please refer to the KL25 sample code:

http://www.nxp.com/assets/downloads/data/en/lab-test-software/KL25_SC.exe 

Folder:kl25_sc_rev10\klxx-sc-baremetal\build\iar\low_power_demo

For LLS and VLLS modes, the wakeup sources are limited to LLWU generated wake-ups, so, please refer to the KL25 sample code to configure the LLWU, and clear the flag in the LLWU interrupt.

   Besides, test LLS, you need to download the code to the board, exit the debug mode, power off and power on the board again, then check the function.

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,405 Views
matteopirro
Contributor I

Thank you for your answer.

I checked the project you suggested me. I don't find relevant differences.

First of all I would ask you: Is it right that the target disconnects when MCU enters in LLS? When I enter in normal stop mode it remains connected and the Run button is enabled so I can  restart debug after MCU wake up. 

Second, I try to be more clear: Using the following code I'm not able to wake up my board. Maybe LLWU works but I'm not able to restart debug? Or maybe I miss some register configurations? Maybe I have to configure clock to correctly work in low power? or other system modules? 

INIT LLWU

/* Clear flags for external sources */
LLWU_F1 |= 0xFF;
LLWU_F2|= 0xFF;

/* Disable all external sources*/
LLWU_PE1 &= 0;
LLWU_PE2 &= 0;
LLWU_PE3 &= 0;
LLWU_PE4 &= 0;

/* Disable all internal sources */
LLWU_ME &= 0;

INIT LLWU_P1

// suppose the pin is the LLWU_P1

/* Enable PE Register */

LLWU_PE1 &= ~(0b11);
LLWU_PE1 |= (0b01);    //RISING EDGE

/* Clear Flag */
LLWU_F1 |= 0x01;

ENABLE INTERRUPT

/* Enable Interrupt */

NVIC_ICPR = 1 << 7 //LLWU interrupt

NVIC_ISER = 1 << 7; //LLWU interrupt

Thank you for your support.

Matteo

0 Kudos
Reply

1,405 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Matteo Pirro,

     Your test low power consumption method really have problem.

     1. Tell you the correct low power consumption test method again:

    1). Download the low power consumption code to the board.

    2). power off the board,  disconnect the debugger

    3). Find a digital multi-meter, adjust it to the current measurement mode, series the two measure pin to the MCU  VDD bus, take FRDM-KL25 board as an example.

   pastedImage_1.png

remove R73, R81, series the two measure pin to J4 pin1 and pin2.

   4). Power on the board again, test the run and LLS current, after wakeup, test the wakeup run mode current again.

   2. About the debugger, from the reference manual, you can get :

pastedImage_2.png

So, if you enter LLS mode, the debugger will be disconnected, even you recovery from the LLS, the debugger can't be connect automatically.

When you test the low power mode, I don't suggest you to use the debug, it can't work in LLS,VLLSx.

Please use the correct measure mode test the current, if the current can't be back to RUN, then tell me again.

Wish it helps you!

 


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply