__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.










share|improve this question






















  • 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 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















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.










share|improve this question






















  • 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 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













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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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


















  • 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 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma