AnsweredAssumed Answered

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

Question asked by Dominik Fehlker on Jan 15, 2015
Latest reply on Jan 30, 2015 by Dominik Fehlker

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

Outcomes