__WFI() will not sleep even with all interrupts disabled and pending cleared - LPC18XX Series
up vote
1
down vote
favorite
Background: I am trying to make my embedded application go to sleep when there is no CAN activity with the __WFI() and then wake up whenever a CAN interrupt is received. Before enterring sleep mode, I disable all interrupts and clear their pending states in the NVIC registers.
To start, right now I'm just trying to make sure that I can sleep forever when I have all interrupts disabled.
for(int i = 0; i < IRQ_MAX; i++)
{
IRQ_ClearPending((IRQ)i);
IRQ_Disable((IRQ)i);
}
__DSB();
__ISB();
__WFI();
MCU_Reset();
I checked the NVIC registers, and they are all set to 0, which should mean that all interrupts are disabled and there are no pending interrupts. However, everytime I execture the WFI (Wait for interrupt) instruction, it will just NOP on me.
Why can I not enter sleep mode? Do I actually have to somehow disable all of my peripherals and disable the interrupts at their source or is there a way to just mask all interrupts minus the CAN?
Thank you for your time. Let me know if there is anything I can do to clarify the question.
c embedded interrupt cortex-m3 lpc
|
show 3 more comments
up vote
1
down vote
favorite
Background: I am trying to make my embedded application go to sleep when there is no CAN activity with the __WFI() and then wake up whenever a CAN interrupt is received. Before enterring sleep mode, I disable all interrupts and clear their pending states in the NVIC registers.
To start, right now I'm just trying to make sure that I can sleep forever when I have all interrupts disabled.
for(int i = 0; i < IRQ_MAX; i++)
{
IRQ_ClearPending((IRQ)i);
IRQ_Disable((IRQ)i);
}
__DSB();
__ISB();
__WFI();
MCU_Reset();
I checked the NVIC registers, and they are all set to 0, which should mean that all interrupts are disabled and there are no pending interrupts. However, everytime I execture the WFI (Wait for interrupt) instruction, it will just NOP on me.
Why can I not enter sleep mode? Do I actually have to somehow disable all of my peripherals and disable the interrupts at their source or is there a way to just mask all interrupts minus the CAN?
Thank you for your time. Let me know if there is anything I can do to clarify the question.
c embedded interrupt cortex-m3 lpc
Are you stepping through the code with a debugger?
– Fiddling Bits
Nov 10 at 18:51
@FiddlingBits yes, but I have tried with the debugger disconnected as well and it is the same behavior.
– LaneL
Nov 10 at 18:54
5
The reason I'm asking is because the debugger may be preventing the device from sleeping.
– Fiddling Bits
Nov 10 at 18:55
1
This code won't disableSysTick
, because that does not go through theNVIC
at all.
– Turbo J
Nov 11 at 10:29
@TurboJ that could expain it. I know for sure that SysTick is still being used by the RTOS, but I thought that the WFI instruction only pertained to NVIC interrupts.I will try and see what it would take to disable the SysTick and if that works.
– LaneL
Nov 12 at 15:18
|
show 3 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Background: I am trying to make my embedded application go to sleep when there is no CAN activity with the __WFI() and then wake up whenever a CAN interrupt is received. Before enterring sleep mode, I disable all interrupts and clear their pending states in the NVIC registers.
To start, right now I'm just trying to make sure that I can sleep forever when I have all interrupts disabled.
for(int i = 0; i < IRQ_MAX; i++)
{
IRQ_ClearPending((IRQ)i);
IRQ_Disable((IRQ)i);
}
__DSB();
__ISB();
__WFI();
MCU_Reset();
I checked the NVIC registers, and they are all set to 0, which should mean that all interrupts are disabled and there are no pending interrupts. However, everytime I execture the WFI (Wait for interrupt) instruction, it will just NOP on me.
Why can I not enter sleep mode? Do I actually have to somehow disable all of my peripherals and disable the interrupts at their source or is there a way to just mask all interrupts minus the CAN?
Thank you for your time. Let me know if there is anything I can do to clarify the question.
c embedded interrupt cortex-m3 lpc
Background: I am trying to make my embedded application go to sleep when there is no CAN activity with the __WFI() and then wake up whenever a CAN interrupt is received. Before enterring sleep mode, I disable all interrupts and clear their pending states in the NVIC registers.
To start, right now I'm just trying to make sure that I can sleep forever when I have all interrupts disabled.
for(int i = 0; i < IRQ_MAX; i++)
{
IRQ_ClearPending((IRQ)i);
IRQ_Disable((IRQ)i);
}
__DSB();
__ISB();
__WFI();
MCU_Reset();
I checked the NVIC registers, and they are all set to 0, which should mean that all interrupts are disabled and there are no pending interrupts. However, everytime I execture the WFI (Wait for interrupt) instruction, it will just NOP on me.
Why can I not enter sleep mode? Do I actually have to somehow disable all of my peripherals and disable the interrupts at their source or is there a way to just mask all interrupts minus the CAN?
Thank you for your time. Let me know if there is anything I can do to clarify the question.
c embedded interrupt cortex-m3 lpc
c embedded interrupt cortex-m3 lpc
asked Nov 10 at 18:40
LaneL
485519
485519
Are you stepping through the code with a debugger?
– Fiddling Bits
Nov 10 at 18:51
@FiddlingBits yes, but I have tried with the debugger disconnected as well and it is the same behavior.
– LaneL
Nov 10 at 18:54
5
The reason I'm asking is because the debugger may be preventing the device from sleeping.
– Fiddling Bits
Nov 10 at 18:55
1
This code won't disableSysTick
, because that does not go through theNVIC
at all.
– Turbo J
Nov 11 at 10:29
@TurboJ that could expain it. I know for sure that SysTick is still being used by the RTOS, but I thought that the WFI instruction only pertained to NVIC interrupts.I will try and see what it would take to disable the SysTick and if that works.
– LaneL
Nov 12 at 15:18
|
show 3 more comments
Are you stepping through the code with a debugger?
– Fiddling Bits
Nov 10 at 18:51
@FiddlingBits yes, but I have tried with the debugger disconnected as well and it is the same behavior.
– LaneL
Nov 10 at 18:54
5
The reason I'm asking is because the debugger may be preventing the device from sleeping.
– Fiddling Bits
Nov 10 at 18:55
1
This code won't disableSysTick
, because that does not go through theNVIC
at all.
– Turbo J
Nov 11 at 10:29
@TurboJ that could expain it. I know for sure that SysTick is still being used by the RTOS, but I thought that the WFI instruction only pertained to NVIC interrupts.I will try and see what it would take to disable the SysTick and if that works.
– LaneL
Nov 12 at 15:18
Are you stepping through the code with a debugger?
– Fiddling Bits
Nov 10 at 18:51
Are you stepping through the code with a debugger?
– Fiddling Bits
Nov 10 at 18:51
@FiddlingBits yes, but I have tried with the debugger disconnected as well and it is the same behavior.
– LaneL
Nov 10 at 18:54
@FiddlingBits yes, but I have tried with the debugger disconnected as well and it is the same behavior.
– LaneL
Nov 10 at 18:54
5
5
The reason I'm asking is because the debugger may be preventing the device from sleeping.
– Fiddling Bits
Nov 10 at 18:55
The reason I'm asking is because the debugger may be preventing the device from sleeping.
– Fiddling Bits
Nov 10 at 18:55
1
1
This code won't disable
SysTick
, because that does not go through the NVIC
at all.– Turbo J
Nov 11 at 10:29
This code won't disable
SysTick
, because that does not go through the NVIC
at all.– Turbo J
Nov 11 at 10:29
@TurboJ that could expain it. I know for sure that SysTick is still being used by the RTOS, but I thought that the WFI instruction only pertained to NVIC interrupts.I will try and see what it would take to disable the SysTick and if that works.
– LaneL
Nov 12 at 15:18
@TurboJ that could expain it. I know for sure that SysTick is still being used by the RTOS, but I thought that the WFI instruction only pertained to NVIC interrupts.I will try and see what it would take to disable the SysTick and if that works.
– LaneL
Nov 12 at 15:18
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242217%2fwfi-will-not-sleep-even-with-all-interrupts-disabled-and-pending-cleared-l%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you stepping through the code with a debugger?
– Fiddling Bits
Nov 10 at 18:51
@FiddlingBits yes, but I have tried with the debugger disconnected as well and it is the same behavior.
– LaneL
Nov 10 at 18:54
5
The reason I'm asking is because the debugger may be preventing the device from sleeping.
– Fiddling Bits
Nov 10 at 18:55
1
This code won't disable
SysTick
, because that does not go through theNVIC
at all.– Turbo J
Nov 11 at 10:29
@TurboJ that could expain it. I know for sure that SysTick is still being used by the RTOS, but I thought that the WFI instruction only pertained to NVIC interrupts.I will try and see what it would take to disable the SysTick and if that works.
– LaneL
Nov 12 at 15:18