PIC24FJ128GA204 can not wake up from deep sleep

481 views Asked by At

I've been trying to wake my PIC controller from deep sleep however I can not wake it up. According to the datasheet it says there are 3 ways to wake it up: 1)RTCC alarm 2)External Interrupt 3)Deep Sleep Watchdog Timer(DSWDT)

I am using the third option because RTCC is kind of hard to initialize and external interrupt is not suitable for my project so I decided to go with DSWDT.

Below there is my deep sleep function. It consumes 80 uA current while in the datasheet it is claimed that it consumes 66 nA in deep sleep.

void  DeepSleep(void)
{
 RCONbits.DPSLP = 0; 
 DSWAKE = 0;         
 RCONbits.RETEN=1;

 DSCONbits.DSEN=1;
 Nop();
 Nop();
 DSCONbits.DSEN=1;
 Sleep();
}

For waking it up, I configured deep sleep watchdog timer in pre processing part. I altered it for 4.2 seconds however it can not even be debugged. The compiler states that there is a problem with the oscillator. I think the deep sleep watchdog timer is not clocked well. What am I suppose to initalize or configure?

Here is my preprocessing configuration:

#pragma config DSWDTPS = DSWDTPSC // (4.228 Secs))
#pragma config DSWDTOSC = LPRC //Low Power RC Oscillator
#pragma config DSBOREN = OFF // Deep Sleep BOR Enable bit (DSBOR Disabled)
#pragma config DSWDTEN = ON // Deep Sleep Watchdog Timer Enable (DSWDT Enabled)
#pragma config DSSWEN = ON // DSEN Bit Enable (Deep Sleep is controlled by the register bit DSEN)
#pragma config PLLDIV = DISABLED // USB 96 MHz PLL Prescaler Select bits (PLL Disabled)
#pragma config I2C1SEL = DISABLE // Alternate I2C1 enable bit (I2C1 uses SCL1 and SDA1 pins)
#pragma config IOL1WAY = ON
1

There are 1 answers

0
PVH_1907 On

It's been solved months ago but I forgot to post the answer. You have to set Release bit of the deep sleep control register two times consecutively after the mcu wakes up. Just let you guys know.