Unexpected behaviour when waking up from LLS stop mode via Cpu_OnLLSWakeUpINT ?

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

Unexpected behaviour when waking up from LLS stop mode via Cpu_OnLLSWakeUpINT ?

1,205 Views
dominikf
Contributor II

Hei all,

After getting the LLWU functionality via an external Pin (LLWU_P6) to work, I still struggle to understand some features when using the LLWU.

I have a Codewarrior project with Processor Expert, running on a FRDM-KL26Z development kit. LLWU_P6 is used to receive a ready signal from an ADC when the ADC is done with its conversion. Until then the MCU should save some power and be in sleep mode.

Case 1: LED on, MCU put to sleep, LED off in Cpu_OnLLSWakeUpINT

The function that sets the MCU to stop mode:

static uint8_t SpiAdc_WaitForReadySignal()

{

  /* Interrupt based solution

   * The MCU is put into STOP mode (LLS - Low Leakage Stop), and is waken up

   * using the SPI MISO / Ready signal from the ADC. The Ready pulse wakes up

   * the MCU from STOP mode using the LLWU (Low Leakage Wake Up) functionality.

   * This is configured in PE, and currently LLWU_P6 /PTC1 is used for the Ready signal.

   */

    Red_LED_ClrVal(Red_LED_DeviceData);    /* Turn on red LED */

    Cpu_SetOperationMode(DOM_STOP, NULL, NULL);

  return ERR_OK;  

}

Events.c , where Cpu_OnLLSWakeUpINT is located:

void Cpu_OnLLSWakeUpINT(void)

{

  /* Write your code here ... */

    volatile uint32_t tmp;

    tmp = Cpu_GetLLSWakeUpFlags();

   

    Red_LED_SetVal(Red_LED_DeviceData);    /* Turn off red LED */ 

}

This is how things look on the scope.

The green LED signal indicates the ADC readout procedure, the red LED indicated entering the sleep mode and exiting it again (see above in the source code).

Instead of turning of the red LED when entering Cpu_OnLLSWakeUpINT, it is only toggled, and never turned off.

TEK00007.PNG.png

Case 2: LED on, MCU put to sleep, LED off in same function

If the code for putting the MCU to sleep is changed to the following:

static uint8_t SpiAdc_WaitForReadySignal()

{

  /* Interrupt based solution

   * The MCU is put into STOP mode (LLS - Low Leakage Stop), and is waken up

   * using the SPI MISO / Ready signal from the ADC. The Ready pulse wakes up

   * the MCU from STOP mode using the LLWU (Low Leakage Wake Up) functionality.

   * This is configured in PE, and currently LLWU_P6 /PTC1 is used for the Ready signal.

   */

    Red_LED_ClrVal(Red_LED_DeviceData);    /* Turn on red LED */

    Cpu_SetOperationMode(DOM_STOP, NULL, NULL);

    Red_LED_SetVal(Red_LED_DeviceData);    /* Turn off red LED */

  return ERR_OK;

}

The Cpu_OnLLSWakeUpINT then does nothing, essentially...

void Cpu_OnLLSWakeUpINT(void)

{

  /* Write your code here ... */

    volatile uint32_t tmp;

    tmp = Cpu_GetLLSWakeUpFlags();

   

//    Red_LED_SetVal(Red_LED_DeviceData);    /* Turn off red LED */

}

And the scope picture of this event looks like this:

Again yellow is the SPI Ready signal, green shows the whole ADC readout procedure, and red LED signal is the time that the mcu is sleeping.

TEK00008.PNG.png

The one source code line turning off the red LED is the only source code line that was changed in the project.

- In case 1, how come the LED never gets turned off in Cpu_OnLLSWakeUpINT, even though the CPU clearly wakes up from its sleep? Is the Cpu_OnLLSWakeUpINT not executed?

- In case 2, what causes the two spikes on the red led signal, they happen 240µs before the yellow spikes on the SPI/Ready signal?

Thanks for your help!

Dominik

Labels (1)
10 Replies

877 Views
dominikf
Contributor II

I thought I write an update to how this issue is going, in case others have the same problems.

After the sporadic waking up of the MCU was traced to noise and EMC issues on the LLWU lines, there developed a new problem. That the MCU would not wake up every time a LLWU signal was send. This could be also seen when using the Pushbutton as LLWU signal. Sometimes a keypress just wouldnt wake up the MCU.

After changing around the pins some more we arrived at a working configuration with using PTC6 as LLWU pin, and disabling PTC3 (pushbutton) as a source.

It seems when using the FRDM-KL26Z, something is picky about which signals to use.

0 Kudos

877 Views
adriancano
NXP Employee
NXP Employee

Hi Dominik,

Can you please share the code to corroborate the behavior you are seeing?

Thank you for the information.

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer

0 Kudos

877 Views
dominikf
Contributor II

Hei Adrian,

thank you for looking into this.

I removed all the ADC related stuff, so that its possible to test on the FRDM board alone. Some delays are added in places where ADC initialization and readout would happen. And there is a long delay in the beginning (blue LED lit) of about 15 seconds, that allows me to set the scope after MCU initialisation. :smileyhappy:

Every 5 seconds the MCU is put into stop mode (Red and green LED are lit simultaneously), and can be woken up via the pushbutton.

Sometimes though the MCU does not wait for the pushbutton, visible by a green blinking of the LED, instead of the yellow (red+green) glow when the MCU is in STOP mode. This would happen from time to time.

This is the same behaviour I see when the ADC is handling the LLWU signal.

The MCU component I copied from the Pe Low power demo code, so that should be correct. As far as I remember the LLWU wakeup pins were the only thing I changed there.

Maybe this is some other setting in PE triggering this behaviour, but I can't see it....

Cheers,

Dominik

0 Kudos

877 Views
Amit_Kumar1
Senior Contributor II

Hi Dominik

Did you check the errata?.

Kind Regards

Amit

0 Kudos

877 Views
dominikf
Contributor II

Hei Amit,

yes, I had checked the erratas for the KL2x series, but didn't see something that would appear related to the issue I am seeing.

In the forums I saw that someone had issues with the Interrupt Priorities, so I changed around on these, but that didn't help either.

Cheers,

Dominik

0 Kudos

876 Views
adriancano
NXP Employee
NXP Employee

Hi,

I apologize for the late response, I was working on this issue but I have some problems to understand exactly the issues you are experimenting. Attached you will find an example I created to test this, I will explained later. First I want to give you some hints and ideas when working with LLS mode in Processor Expert and none Processor expert projects.

  • It is not necessary to configure the PORT and GPIO registers for the Pin used as the wake up source. The pin pad is connected directly to the LLWU, then the LLWU is sensitive to the pin changes. This is because the PORT and GPIO registers remain static during LLS mode.
  • In Processor Expert setting the External Pins is enough to say the LLWU that such pin will be a wake up source:

llwu pin.png

  • When exiting LLS mode the code line before the GoToLLSMode instruction will be excecuted and after that the code will run normally.
  • Is better to have a small code in the Interrupt Service Routine (ISR) then try to just set flags that will be checked after the ISR ends.
  • Debug is not possible during LLS mode.
  • When debugging the application, after the LLS mode enter the debug mode will be disconnected, then it is not possible to return to debug mode. In this case if you continue running the application without disconnecting the board after the Connection Lost message in CodeWarrior the MCU will be trying to restart the Debug mode and you application will not run normally. The recommend way to test the application is in standalone mode: after flashing the program into the device disconnect and connect again the board.

As I mentioned attached you will find a simple project I created to demonstrate the use of External pins to wake up the MCU from LLS mode.

The philosophy of the code is the next:

  1. Wait 5 seconds
  2. Leds Blue+Green are toggled.
  3. MCU moves to LLS mode
  4. Wait for a change in the Wake up pins. The pins are: PTC3 (connected to SW1), PTC5 (connected to J4[9]) or PTC1 (connected to J4[12]).
  5. When the MCU is waken up from one of this sources the Cpu_OnLLSWakeUpINT is called and set some flags.
  6. The code returns to the line after the Cpu_SetOperationMode(DOM_STOP,NULL,NULL) function and evaluates the flags: If PTC3 was the source Blue led is toggled, if PTC5 was the source Green led is toggled and if PTC3 nor PTC5 (this means PTC1 or other source) were the source Red led is toggled.
  7. The steps are repeated.

Please refer to the attached example for better explanation.

If you have any question please do not hesitate to ask.


Hope this information can help you

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

876 Views
dominikf
Contributor II

Actually, one more question.

I see that the CPU component is of MC4 package type in your project.

How come I still can run your project on the FRDM-KL26Z which actually has a LH4 type mounted on it?

Cheers,

Dominik

0 Kudos

876 Views
adriancano
NXP Employee
NXP Employee

Hi,

I apologize, I did not see this question before.

That is not a big problem, PEx uses the package type to know which pins are available to use, if you set a big package you will be able to use pins that are not available in a smaller package. You can change easily the package type in the CPU component selecting between different packages.


Hope this information can help you

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

876 Views
dominikf
Contributor II

Hei Adrian,

and thank you for the informative post - several interesting points there.

I wasn't aware that debug mode can not be used anymore after entering the LLS state. Also interesting that you should name that the recommended way is to disconnect and reconnect the board again. I was wondering about the recommended way, since sometimes I got different behavior if I started the application from Codewarrior (right click on project -> run as) or if I would disconnect and reconnect.

What do you mean by:

  • When exiting LLS mode the code line before the GoToLLSMode instruction will be excecuted and after that the code will run normally.

Do you mean actually "Cpu_SetOperationMode(DOM_STOP,NULL,NULL);" with GoToLLSMode, or do you mean an ASM instruction?

Now the really interesting bit:

When running your project, I got similar behavior, even though no input signal was given to the input pins. Since I had soldered headers to the board and wires to TP10, 11 and 13, I tried with a brand new and bare FRDM-KL26Z. There I could wake up the CPU by putting a piece of plastic coated wire close to J4 12 or J4 09, although J4 09 seems more sensitive than J4 12. Is there some documentation around on how sensitive the LLWU pins actually are?

After looking at the layout (Thanks to Bent!) looks like this is a problem with the tightly routed development kit and using only two layers on the card.

I guess going from here is adding an external pulldown to the LLWU pins used.

Cheers,

Dominik

0 Kudos

876 Views
adriancano
NXP Employee
NXP Employee

Hi,

Yes, when I say GoToLLSMode instruction I am referring to Cpu_SetOperationMode(DOM_STOP,NULL,NULL).

The pins connected to the LLWU has the same characteristics that you can see in the Datasheet. Please refer to the sections AC electrical characteristics and Voltage and current operating requirements, there you can see the VIH Input High Voltage and the VIL Input Low Voltage which are the voltage levels for the pins.

Definitively you need to set a pull down or pull up to those pins to ensure a known level.


Hope this information can help you

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------