How to wake Pic32 from sleep mode?
I am trying to keep PIC32 in sleep mode on boot up. And when the power button is pressed the Pic32 should exit the sleep mode and wake up.
I am able to put PIC32 in sleep mode but I am not sure how I can trigger it to wake up on button press.
Is it possible if I can trigger an interrupt whenever the user presses the power button and thus wake the PIC32?
I am using microchip harmony framework and am quite new to this can someone please suggest how I can achieve this?
To put PIC32 I am using the PowerEnterMode function of harmony. To wake up PIC32 I have tried using the watch dog timer following the sample project provided with microchip harmony but couldn't get it to work.
I also read that I can use external interrupt to set it up but I don't know how to set it up.
I have added my code below.
void APP_Initialize ( void )
{
DRV_ADC_Open();
DRV_ADC_Start();
PLIB_ADC_Enable(ADC_ID_1);
SPIHandle = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_READWRITE );
DelayMs(100);
SYS_DEVCON_PowerModeEnter(SYS_POWER_MODE_IDLE);
appData.state = APP_STATE_POWER_UP;
}
void APP_Tasks (void)
{
switch ( appData.state )
{
case APP_STATE_POWER_UP:
{
uint8_t pwrButton;
pwrButton = PWR_BTNStateGet() ;
if (npwrButton == 0) // If button is pressed
{
PwrButtonDebounce += 1; // Increment the pressed timer
DelayMs(10);
} else
{
PwrButtonDebounce = 0; // Clear the Debounce Timer
}
if (PwrButtonDebounce == MAX_DEBOUNCE) // Debounced....
{
// Here Wake up routine on button press
appData.state = APP_STATE_INIT;
}
}
}
I expect that whenever I press the power button the Pic32 should come in the APP_STATE_POWER_UP state and on debounce go in the initialization state but It never comes in this state.
Can someone suggest how I can set this up?
c mplab pic32
add a comment |
I am trying to keep PIC32 in sleep mode on boot up. And when the power button is pressed the Pic32 should exit the sleep mode and wake up.
I am able to put PIC32 in sleep mode but I am not sure how I can trigger it to wake up on button press.
Is it possible if I can trigger an interrupt whenever the user presses the power button and thus wake the PIC32?
I am using microchip harmony framework and am quite new to this can someone please suggest how I can achieve this?
To put PIC32 I am using the PowerEnterMode function of harmony. To wake up PIC32 I have tried using the watch dog timer following the sample project provided with microchip harmony but couldn't get it to work.
I also read that I can use external interrupt to set it up but I don't know how to set it up.
I have added my code below.
void APP_Initialize ( void )
{
DRV_ADC_Open();
DRV_ADC_Start();
PLIB_ADC_Enable(ADC_ID_1);
SPIHandle = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_READWRITE );
DelayMs(100);
SYS_DEVCON_PowerModeEnter(SYS_POWER_MODE_IDLE);
appData.state = APP_STATE_POWER_UP;
}
void APP_Tasks (void)
{
switch ( appData.state )
{
case APP_STATE_POWER_UP:
{
uint8_t pwrButton;
pwrButton = PWR_BTNStateGet() ;
if (npwrButton == 0) // If button is pressed
{
PwrButtonDebounce += 1; // Increment the pressed timer
DelayMs(10);
} else
{
PwrButtonDebounce = 0; // Clear the Debounce Timer
}
if (PwrButtonDebounce == MAX_DEBOUNCE) // Debounced....
{
// Here Wake up routine on button press
appData.state = APP_STATE_INIT;
}
}
}
I expect that whenever I press the power button the Pic32 should come in the APP_STATE_POWER_UP state and on debounce go in the initialization state but It never comes in this state.
Can someone suggest how I can set this up?
c mplab pic32
add a comment |
I am trying to keep PIC32 in sleep mode on boot up. And when the power button is pressed the Pic32 should exit the sleep mode and wake up.
I am able to put PIC32 in sleep mode but I am not sure how I can trigger it to wake up on button press.
Is it possible if I can trigger an interrupt whenever the user presses the power button and thus wake the PIC32?
I am using microchip harmony framework and am quite new to this can someone please suggest how I can achieve this?
To put PIC32 I am using the PowerEnterMode function of harmony. To wake up PIC32 I have tried using the watch dog timer following the sample project provided with microchip harmony but couldn't get it to work.
I also read that I can use external interrupt to set it up but I don't know how to set it up.
I have added my code below.
void APP_Initialize ( void )
{
DRV_ADC_Open();
DRV_ADC_Start();
PLIB_ADC_Enable(ADC_ID_1);
SPIHandle = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_READWRITE );
DelayMs(100);
SYS_DEVCON_PowerModeEnter(SYS_POWER_MODE_IDLE);
appData.state = APP_STATE_POWER_UP;
}
void APP_Tasks (void)
{
switch ( appData.state )
{
case APP_STATE_POWER_UP:
{
uint8_t pwrButton;
pwrButton = PWR_BTNStateGet() ;
if (npwrButton == 0) // If button is pressed
{
PwrButtonDebounce += 1; // Increment the pressed timer
DelayMs(10);
} else
{
PwrButtonDebounce = 0; // Clear the Debounce Timer
}
if (PwrButtonDebounce == MAX_DEBOUNCE) // Debounced....
{
// Here Wake up routine on button press
appData.state = APP_STATE_INIT;
}
}
}
I expect that whenever I press the power button the Pic32 should come in the APP_STATE_POWER_UP state and on debounce go in the initialization state but It never comes in this state.
Can someone suggest how I can set this up?
c mplab pic32
I am trying to keep PIC32 in sleep mode on boot up. And when the power button is pressed the Pic32 should exit the sleep mode and wake up.
I am able to put PIC32 in sleep mode but I am not sure how I can trigger it to wake up on button press.
Is it possible if I can trigger an interrupt whenever the user presses the power button and thus wake the PIC32?
I am using microchip harmony framework and am quite new to this can someone please suggest how I can achieve this?
To put PIC32 I am using the PowerEnterMode function of harmony. To wake up PIC32 I have tried using the watch dog timer following the sample project provided with microchip harmony but couldn't get it to work.
I also read that I can use external interrupt to set it up but I don't know how to set it up.
I have added my code below.
void APP_Initialize ( void )
{
DRV_ADC_Open();
DRV_ADC_Start();
PLIB_ADC_Enable(ADC_ID_1);
SPIHandle = DRV_SPI_Open(DRV_SPI_INDEX_0, DRV_IO_INTENT_READWRITE );
DelayMs(100);
SYS_DEVCON_PowerModeEnter(SYS_POWER_MODE_IDLE);
appData.state = APP_STATE_POWER_UP;
}
void APP_Tasks (void)
{
switch ( appData.state )
{
case APP_STATE_POWER_UP:
{
uint8_t pwrButton;
pwrButton = PWR_BTNStateGet() ;
if (npwrButton == 0) // If button is pressed
{
PwrButtonDebounce += 1; // Increment the pressed timer
DelayMs(10);
} else
{
PwrButtonDebounce = 0; // Clear the Debounce Timer
}
if (PwrButtonDebounce == MAX_DEBOUNCE) // Debounced....
{
// Here Wake up routine on button press
appData.state = APP_STATE_INIT;
}
}
}
I expect that whenever I press the power button the Pic32 should come in the APP_STATE_POWER_UP state and on debounce go in the initialization state but It never comes in this state.
Can someone suggest how I can set this up?
c mplab pic32
c mplab pic32
edited Jan 2 at 11:58
Mike
2,0071621
2,0071621
asked Dec 28 '18 at 12:49
abdullahabdullah
63
63
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You should use Change Notification interrupt.
Enable the CN interrupt on the pin that you have your button and it will wake your device when pressed.
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
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%2f53958877%2fhow-to-wake-pic32-from-sleep-mode%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should use Change Notification interrupt.
Enable the CN interrupt on the pin that you have your button and it will wake your device when pressed.
add a comment |
You should use Change Notification interrupt.
Enable the CN interrupt on the pin that you have your button and it will wake your device when pressed.
add a comment |
You should use Change Notification interrupt.
Enable the CN interrupt on the pin that you have your button and it will wake your device when pressed.
You should use Change Notification interrupt.
Enable the CN interrupt on the pin that you have your button and it will wake your device when pressed.
answered Jan 5 at 11:40
DamienDamien
788316
788316
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f53958877%2fhow-to-wake-pic32-from-sleep-mode%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