title: PIC24FJ128GA204 can not wake up from deep sleep
body: <p>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)</p>
  <p>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.</p>
  <p>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.</p>
  <pre><code>void  DeepSleep(void)
  {
   RCONbits.DPSLP = 0; 
   DSWAKE = 0;         
   RCONbits.RETEN=1;
  
   DSCONbits.DSEN=1;
   Nop();
   Nop();
   DSCONbits.DSEN=1;
   Sleep();
  }
  </code></pre>
  <p>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?</p>
  <p>Here is my preprocessing configuration:</p>
  <pre><code>#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
  </code></pre>