Wakeup problem in LLS mode !!

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

Wakeup problem in LLS mode !!

Jump to solution
1,416 Views
Nana
Contributor II

I'm using K60N512 and mode of LLS low power  -> power_mode=LPM_OPERATION_MODE_STOP;

after setting ok the sources for wake up and watching to the registers value before entering in sleep mode. The core is not recovering from sleep. The problem is the example what is wake up by the RTC interrupt is working but by pin wakeup is not working. I've tested the connection before entering in sleep and the isr for that pin is working.

this is the code for pin initialization

SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK|SIM_SCGC5_PORTB_MASK|SIM_SCGC5_PORTC_MASK       |SIM_SCGC5_PORTD_MASK|SIM_SCGC5_PORTE_MASK;    PORTC_PCR3=PORT_PCR_MUX(1)|PORT_PCR_IRQC(0xA)|PORT_PCR_PE_MASK|PORT_PCR_PS_MASK;    _int_install_isr(INT_PORTC,(pointer)my_isr,NULL);    _bsp_int_init(INT_PORTC,4,0,TRUE);

 and this is the code for setting sleep mode:

power_mode = LPM_OPERATION_MODE_STOP;        printf("**************** Current Mode : %s **********************\n", predefined_power_modes_names[power_mode]);                set.PE1=1;//LPM_CPU_OPERATION_MODES[power_mode].PE1|0x01;        set.PE2=LPM_CPU_OPERATION_MODES[power_mode].PE2+2;        set.PE3=LPM_CPU_OPERATION_MODES[power_mode].PE3;        set.PE4=LPM_CPU_OPERATION_MODES[power_mode].PE4;        set.FLAGS=LPM_CPU_OPERATION_MODES[power_mode].FLAGS;        set.ME=LPM_CPU_OPERATION_MODES[power_mode].ME;        set.MODE_INDEX=LPM_CPU_OPERATION_MODES[power_mode].MODE_INDEX;                        pstOpMode = &set;                //_lpm_set_cpu_operation_mode(pstOpMode,power_mode);       /* if (MQX_OK != _lpm_install (&set, power_mode))        {        printf ("Error during LPM install!\n");        }*/        display_operation_mode_setting(power_mode);        printf(        "Info: STOP mode is mapped to Kinets LLS mode by default.\n"        "      Core and most peripherals are inactive in this mode, reacting only to\n"        "      specified wake up events. The events can be changed in BSP (init_lpm.c).\n"        "      Serial line is turned off in this mode. The core will wake up from\n"        "      RTC interrupt.\n");                /* Wake up in 60 seconds */        set_rtc_alarm(20);        //enable WAKE up pin 0 from LLWU as pin PTE1, and B10 connector on tower)        //LPM_CPU_OPERATION_MODES[power_mode].PE1=(uint_8)0x01;       _int_install_isr(INT_LLW,(pointer)llwu_isr,NULL);       _bsp_int_init(INT_LLW,2,0,TRUE);        /* Change the operation mode */        printf ("\nSetting operation mode to %s ... \n", predefined_power_modes_names[power_mode]);        _lpm_set_operation_mode (power_mode);               /* Return to RUN mode */        _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);                printf("\nCore is awake. Moved to next operation mode.\n");

 and this is the interrupt for wakeup:

void llwu_isr(void){ _lpm_wakeup_core();  _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);// printf("Core wake up by LLWU PIN0 source\n"); LLWU_CS |= LLWU_CS_ACKISO_MASK;    // clear LLWU acknowledge flag     LLWU_F1 = 0xFF;            // clear wakeup flags     LLWU_F2 = 0xFF;            // clear wakeup flags     LLWU_F3 = 0xFF;            // clear wakeup flags}

 

0 Kudos
1 Solution
600 Views
PetrM
Senior Contributor I

Hello,

 

you can't use LPM API functions within ISR routine. The only exception is _lpm_wakeup_core(). So please remove _lpm_set_operation_mode(RUN) from your LLWU ISR.

One more thing: do not feed _lpm_set_cpu_operation_mode() using your own settings while LPM is installed with other settings, that's not safe operation. The power_mode variable is out of range of your operation modes array in your code.

 

Regards,

PetrM

 

View solution in original post

0 Kudos
5 Replies
600 Views
donejtaelshani
Contributor II

I am having problems waking up from sleep/stop mode,I set the external pin in LLWU  setting enabled and in the routine of detecting that interrupt set

Cpu_SetOperationMode(DOM_RUN, NULL, NULL); but I think the processor isn't detecting any interrupt. Also when entering the stop mode (VLLS) the board losses connection . All I need is a blinking led and via an external interrupt(falling edge) to set the processor in sleep and wake it up when rising edge on the interrupt is detected. I am using processor expert.

main looks like this :

int main(void)

{

  /* Write your local variable definition here */

    

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

EInt1_Enable();

  Cpu_VLPModeEnable();

  while(1){

  Bit1_SetVal();WAIT1_Waitms(100);

  Bit1_ClrVal();WAIT1_Waitms(100);

}

in events.c

void EInt1_OnInterrupt(void)

{

  WAIT1_Waitms(100);

  if (EInt1_GetVal())

  {

   Cpu_SetOperationMode(DOM_RUN, NULL, NULL);/* Write your code here ... */}

else {

  Cpu_SetOperationMode(DOM_STOP, NULL, NULL);

  }

}

Also tried this :

void Cpu_OnLLSWakeUpINT(void)

{

v = Cpu_SetOperationMode(DOM_RUN, NULL, NULL);// v is a char

Bit1_SetVal();WAIT1_Waitms(100);

  Bit1_ClrVal();WAIT1_Waitms(100);// just to see if it is entering this function

}

0 Kudos
600 Views
danielchai
Senior Contributor I

Hi,

You need the configure the wake up source and enable the IRQ.

0 Kudos
600 Views
c0170
Senior Contributor III

Hi Nana,

 

First of all, before i even check your code, have you checked the errata for K60 board for your maskset? What's your maskset? There was reported an issue with wake up from LLS mode .

 

Regards,

MartinK

0 Kudos
600 Views
Nana
Contributor II

I read the errata document "Mask Set Errata for Mask 4N30D" and I'm not using the NMI interrupt for wakeup the cpu from LLS state. And second I have connect the debugger to the board. 

For wakeup source I use PIN PTC3.

So the LPM_initialization is this :

 // LPM_OPERATION_MODE_STOP    {        LPM_CPU_POWER_MODE_KINETIS_LLS,             // Index of predefined mode        0,                                          // Additional mode flags        LLWU_PE1_WUPE0(3), //was 0                  // Mode wake up events from pins 0..3        LLWU_PE2_WUPE7(2),                          // Mode wake up events from pins 4..7        0,                              // Mode wake up events from pins 8..11 - SW3 rising        0,                                          // Mode wake up events from pins 12..15        LLWU_ME_WUME5_MASK                          // Mode wake up events from internal input sources - RTC    }

 

0 Kudos
601 Views
PetrM
Senior Contributor I

Hello,

 

you can't use LPM API functions within ISR routine. The only exception is _lpm_wakeup_core(). So please remove _lpm_set_operation_mode(RUN) from your LLWU ISR.

One more thing: do not feed _lpm_set_cpu_operation_mode() using your own settings while LPM is installed with other settings, that's not safe operation. The power_mode variable is out of range of your operation modes array in your code.

 

Regards,

PetrM

 

0 Kudos