Interrupt doesn't always work for coming out of LLS and Wait

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

Interrupt doesn't always work for coming out of LLS and Wait

Jump to solution
4,507 Views
lander
Contributor IV

I'm using k20d72m tower and I'm working on going into low power and using an external interrupt to come out of low power. I think I have most of what I need code wise and CPU set up wise but I will put attachments of my code and such.

I have an infinite for loop that uses a PE timer that counts to 3 then goes into a while loop that holds the functions necessary for low power mode. Once the interrupt is detected, it goes out of the while loop and resets the timer and starts the cycle again. I do have a GPIO component for the external interrupt.

My problem is that when coming out of Wait, when I press the external interrupt less than five seconds (five seconds is an estimate) after it went into Wait mode, then the interrupt works but when I wait for more than five seconds, it takes two pushes of the external interrupt before it comes out of Wait mode. Then, for coming out of LLS mode, the external interrupt works once then doesn't work again. But, if I unplug and replug the device from power, it works whenever I use the interrupt and when I press Reset, it just never goes into LLS.

Labels (1)
1 Solution
4,123 Views
chris_brown
NXP Employee
NXP Employee

Hi Lander,

Always happy to take a look and try to help out.

So your code looks pretty good except for a couple of things.

1) The 3rd line of code in your enter_lls() routine is actually going to set every bit in that register.  This will put the RUNM and STOPM bit fields in reserved values (yikes!).  So instead, try writing SMC_PMCTRL |= SMC_PMCTRL_STOPM(0); and see if that helps things.

2) Your end_lls() routine is actually unnecessary where you have called it in your main function.  The code in this function should actually be in your LLWU interrupt routine.

Also, if you want to try using the PEx functions for entering low power modes, try looking at the PEx_low_power_demo in the KL25_SC code package.  It's code for a different part, but the low power entry functions will still be called the same way so it will still be relevant.  If you have any trouble with that code package, please let me know.

http://www.freescale.com/files/32bit/software/KL25_SC.exe?WT_TYPE=BSDL&WT_VENDOR=FREESCALE&WT_FILE_F...

Thanks,

Chris

View solution in original post

0 Kudos
Reply
11 Replies
4,123 Views
lander
Contributor IV

Here is my main and low power functions.

0 Kudos
Reply
4,123 Views
chris_brown
NXP Employee
NXP Employee

Hi Lander,

This all sounds very strange.  I have a couple of questions that I have to ask.

1) Why are you using your own LLS/Wait entry function as opposed to the Processor Expert functions?  This might have something to do with the issue (as I can't see your enter_lls and enter_Wait functions).

2) What is your end_lls function doing?  Can we see it as well?

Thanks,

Chris

0 Kudos
Reply
4,123 Views
lander
Contributor IV

Chris,

     I didn't realize there were PE LLS and Wait functions. I was going off the demo code that was available. I'll show you my enter_lls, end_lls,  and enter_Wait functions attached.

I'm really new at all of this, so thank you for taking your time,

Lander

enter_lls.jpgenter_wait.jpg

Message was edited by: Liz Anderson, format of photos

0 Kudos
Reply
4,124 Views
chris_brown
NXP Employee
NXP Employee

Hi Lander,

Always happy to take a look and try to help out.

So your code looks pretty good except for a couple of things.

1) The 3rd line of code in your enter_lls() routine is actually going to set every bit in that register.  This will put the RUNM and STOPM bit fields in reserved values (yikes!).  So instead, try writing SMC_PMCTRL |= SMC_PMCTRL_STOPM(0); and see if that helps things.

2) Your end_lls() routine is actually unnecessary where you have called it in your main function.  The code in this function should actually be in your LLWU interrupt routine.

Also, if you want to try using the PEx functions for entering low power modes, try looking at the PEx_low_power_demo in the KL25_SC code package.  It's code for a different part, but the low power entry functions will still be called the same way so it will still be relevant.  If you have any trouble with that code package, please let me know.

http://www.freescale.com/files/32bit/software/KL25_SC.exe?WT_TYPE=BSDL&WT_VENDOR=FREESCALE&WT_FILE_F...

Thanks,

Chris

0 Kudos
Reply
4,123 Views
lander
Contributor IV

Chris,

The PEx_low_power_demo helped a lot!! My project is coming together.

Thank you,

Lander

4,123 Views
chris_brown
NXP Employee
NXP Employee

Good to hear!!  Glad I could help.

~Chris

4,123 Views
lander
Contributor IV

Hi Chris,

Turns out I have another question that you may be able to answer. So I used the low power PE code from the KL25Z sample codes and I'm coming across an issue for coming out of VLLSx mode. I am able to come out of low power with a LLWU interrupt but when it comes to the second time around, a LLWU interrupt doesn't work anymore.

I was reading that there are some flags I need to reset but I just am lost on which ones to reset...

I'm using the blue touch as an LLWU for VLLSx and here is my code...

PORTB_PCR2 = PORT_PCR_PS_MASK|PORT_PCR_PE_MASK|PORT_PCR_PFE_MASK|PORT_PCR_IRQC(10)|PORT_PCR_MUX(1);

// RESET SOME PINS HERE??

LLWU_PE2 = LLWU_PE2_WUPE5(3);

Wake_Up_Enable();

Cpu_SetOperationMode(DOM_STOP,NULL,NULL);

if(TmrWkupFlg)

     TmrWkupFlg = FALSE;

Wake_Up_Disable();

Thank you for your help.

0 Kudos
Reply
4,123 Views
chris_brown
NXP Employee
NXP Employee

Hi Lander,

So you say that it doesn't work the second time around?  So you enter VLLSx after a POR, and you are able to wake-up with an LLWU pin this time.  Then you go back to VLLSx and can't wake-up using an LLWU pin this time.  Is that correct?  Or are you entering LLS first and waking using an LLWU pin?

Thanks,

Chris

0 Kudos
Reply
4,123 Views
lander
Contributor IV

Chris,

Right, it doesn't work a second time around. So I enter VLLSx then use LLWU to wake-up, then I enter VLLSx again and try to wake-up with LLWU but it doesn't wake-up.

Thanks,

Lander

0 Kudos
Reply
4,123 Views
chris_brown
NXP Employee
NXP Employee

Hi lander,

It's been a while.  Sorry for the late response but I've been tied up on projects.  Are you handling ACKISO correctly?  ACKISO can be an easy thing to miss.  See the picture below for how it is handled in the low power demo.  Note that you may have to have more code than this (because you should be re-configuring your clock and any necessary pins before servicing ACKISO, but in the low power demo it is OK to handle ACKISO this way). 

UserCodeB4Init.png

~Chris

0 Kudos
Reply
4,123 Views
lander
Contributor IV

Thank you for your reply, we actually decided not to use the k20 and went with a different microcontroller.

Have a great week!

0 Kudos
Reply