Helpful ReplyHot!PIC24FJ256GB406 Deep Sleep _INT0 and RTCC

Author
olver62
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2016/08/29 09:42:05
  • Location: 0
  • Status: offline
2017/04/26 08:42:26 (permalink)
0

PIC24FJ256GB406 Deep Sleep _INT0 and RTCC

Hi All,
i'm optimising the consumption of my board, and i'm facing to this issue:
I tested many ways to go in deep sleep mode but i can only go in Idle and Sleep mode.
 
The board is running whith a 20Mhz crystal, no PLL, and the RTC with le LPRC (tested).
First I wanted to only woke up the chip by INT_0.
I disabled global Interrupts, Enabled the INT0 interrupt and go to deep sleep (set DSCONbits.DSEN 2 times, with nops then Sleep();)
    asm("disi #10");
    DSCONbits.DSEN = 1; //enter deep sleep
    DSCONbits.DSEN = 1; //enter deep sleep
    Nop();
    Nop();
    Nop();
    DSCONbits.DSEN = 1; //enter deep sleep
    DSCONbits.DSEN = 1; //enter deep sleep
    Sleep();

 
The pic correctly go and woke up from sleep (RCONbits.SLEEP  checked at boot up), but not from deep Sleep (RCONbits.DPSLP value is 0).
i also get a Trap flag (i think it's because i have no handler for the INT0 interrupt...)
 
Did you already had this problem?
Do you know some possible raisons of going into Sleep instead of going into deepSleep ?
 
thank you!
#1
olver62
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2016/08/29 09:42:05
  • Location: 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/04/26 09:33:52 (permalink)
3 (1)
Update:
I succeed in going to deep Sleep by this code:
 
    DSWAKE=0;

    _INT0IF=0;
    _INT0IE=1;
    
    DSCON=0x8000;
    DSCON=0x8000;

    Sleep();

 
but now it don't wake up (only by MCLR...)
#2
olver62
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2016/08/29 09:42:05
  • Location: 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/04/27 05:17:37 (permalink)
0
Hi all, 
I succeded in waking up from RTC (DSRTCC bit is set at wakeup), i have done many cycle (wake/sleep) and it works well.
But it's realy hard to wake from INT0.
I succeded one time, by adding 3 nop() beetwin DSCONs and Sleep(), but reflashing with the same programme  is no more working...
 
Thanks for your Help!
#3
olver62
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2016/08/29 09:42:05
  • Location: 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/07/28 09:12:13 (permalink)
0
Hi All, i put this feature aside for a moment, but it's time to work on it again.
I have made some measurements.
In Sleep mode i am consuming around 2 mA, and in deep Sleep less than 200uA (the board have GPS module in hibernation mode)
 
In sleep Mode, there is no problem (wake up from RTC and INT_0 (reset instruction in Interrupt Handler))
But in deep Sleep mode, the RTC Alam cause an incease of current (consuming around 12mA), oscillator starting running, but nothing else...
 
The board is well starting when i put power on it (similar to POR a assume), or whith MCLR.
 
Is there a trick to wakeup from deepSleep?
 
thanks!
#4
RISC
Super Member
  • Total Posts : 4210
  • Reward points : 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/07/28 14:19:18 (permalink)
3 (1)
Hi,
Do you have a 32kHz XTAL on your board.
Even if this oscillator is active it should be less than 100uA.
If you see 12mA, one of the main oscillator is running (either internal one or external).
The RTCC can run while the main oscillator stopped if a 32kHz XTAL is mounted as SOSC.
Regards
#5
olver62
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2016/08/29 09:42:05
  • Location: 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/07/29 03:10:25 (permalink)
0
Ho, thanks for the answer,
The only external oscilator is a 20Mhz, for normal operations.
Concerning the RTC, there is an internal 31KHz LPRC running.
The extra consumption (less than 200uA) is due (i think) to output pin states (I have to maintained some states for peripherals.)
 
At wakeup, the main Oscilator is in fact Running, but i can't see anything other moving (no leds, no serials...)
 
best regards
 
#6
olver62
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2016/08/29 09:42:05
  • Location: 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/07/31 07:26:32 (permalink) ☄ Helpfulby Fantalucio 2017/08/01 05:31:49
0
I have some News,
I deseperately tried to clear ReleaseBit in DSCON register, by clearing it two times at startup (like write protection mechanism)... and it seems to work.
 
#7
olver62
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2016/08/29 09:42:05
  • Location: 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/08/12 04:54:25 (permalink)
0
Hi everyone!
 
It's well working with RTC (waking up from deep SLeep), but impossible with INT0...
before entering deep Sleep reset Remaple pin, set INT0 pin as input, disable Analog, Enable INT0, with priority=7, and clear _INT0IF ... but changing state of the pin, do nothing...
 
does anyone can help me?
 
thanks!
#8
RISC
Super Member
  • Total Posts : 4210
  • Reward points : 0
  • Status: offline
Re: PIC24FJ256GB406 Deep Sleep _INT0 and RTCC 2017/08/14 05:36:45 (permalink)
3 (1)
Hi,
Read carefully the DEEP SLEEP documentation .
Section 39.3.4.3 :

The device can be awakened from Deep Sleep mode by a MCLR, POR, RTCC, INT0 I/O pin interrupt or DSWDT event. After waking, the device performs a POR. When the device is released from Reset, code execution will begin at the device’s Reset vector....

 
Section 39.3.4.5

During Deep Sleep, the general purpose I/O pins will retain their previous states. Pins that are configured as inputs (TRIS bit set) prior to entry into Deep Sleep will remain high-impedance during Deep Sleep. Pins that are configured as outputs (TRIS bit clear) prior to entry into Deep Sleep will remain as output pins during Deep Sleep. While in this mode, they will drive the output level determined by their corresponding LAT bit at the time of entry into Deep Sleep. Once the device wakes back up, all I/O pins will continue to maintain their previous states, even after the device has finished the POR sequence and is executing application code again. Pins configured as inputs during Deep Sleep will remain high-impedance, and pins configured as outputs will continue to drive their previous value. 

Regards
#9
Jump to:
© 2017 APG vNext Commercial Version 4.5