Hot!Multiple Sleep Wake-Ups with WDT/Deep Sleep

Author
labeardslee
Starting Member
  • Total Posts : 23
  • Reward points : 0
  • Joined: 2017/07/30 09:23:14
  • Location: 0
  • Status: offline
2018/06/13 20:33:05 (permalink)
0

Multiple Sleep Wake-Ups with WDT/Deep Sleep

Hi,
        I'm using a PIC32MX274 XLP starter kit with a PIC32MX274F256D MCU. I'm trying to use the watchdog timer to wake the device up from sleep multiple times. Basically, I'm trying to get an extended sleep mode by having the device sleep for the max WDT time out period and then go right back to sleep. I'm able to enter sleep mode once and get the WDT to wake the device, but when I try to use a loop to do multiple sleep periods with the WDT waking the device I find that the MCU never seems to wake-up.
 
Here is my code:

case APP_STATE_SLEEP:
        {  
            //uint8_t i = 0;
            //Stop the Timer
            DRV_TMR0_Stop();
        
            //Switch to the low power RC oscillator
            SYSKEY = 0; // ensure OSCCON is locked
            SYSKEY = 0xAA996655; // Write Key1 to SYSKEY
            SYSKEY = 0x556699AA; // Write Key2 to SYSKEY
            OSCCONbits.NOSC=0x3;
            OSCCONSET = 0x00000001; //Set OSWEN to enable Oscillator switch
            
            //Lock the device
            SYSKEY = 0x33333333;

            
            for(NUMBER_SLEEP_CYCLES = 0; NUMBER_SLEEP_CYCLES < 3; NUMBER_SLEEP_CYCLES++){
                
                SYS_WDT_Enable(false);
                OSCCONbits.SLPEN = 1;
                //Enter the power saving mode
                asm volatile("WAIT");
                SYS_WDT_Disable();
     
              }
            
            while(1){
                    BSP_LEDOff(BSP_LED_RED);
                    BSP_LEDOn(BSP_LED_GREEN);
                    //printf("%u\r", NUMBER_SLEEP_CYCLES);
                    //printf("Hello World");
              }
        }

 
I've also tried resetting the WDT timer instead of disabling/enabling it, but it didn't seem to help.
 
On a related note, an alternative would be to use the Deep Sleep mode, which seems to have a much longer timeout period for the Deep Sleep WDT. But, I'm unable to get the MCU to enter deep sleep. According the manual, I think a wait command with the DEVCFG2 settings should make the device enter deep sleep on a wait command, but I haven't been able to get this to work.
 

#pragma config FPLLIDIV =   DIV_2
#pragma config FPLLICLK =   PLL_FRC
#pragma config FPLLMUL =    MUL_16
#pragma config FPLLODIV =   DIV_2
#pragma config DSBOREN =    ON
#pragma config DSWDTPS =    DSPS13
#pragma config DSWDTOSC =   LPRC
#pragma config DSWDTEN =    ON
#pragma config FDSEN =      ON
#pragma config UPLLIDIV =   DIV_3
#pragma config UPLLEN =     OFF

 
Does anyone have any suggestions? Thanks!
#1

0 Replies Related Threads

    Jump to:
    © 2018 APG vNext Commercial Version 4.5