Menu

Current consumption during sleep

Help
2015-05-07
2015-05-21
  • David Stephenson

    I'm using a 16F1789. I am using sleep mode to switch off the device and an interrupt to wake up again. Normally, on other devices, I can get the power down to 100 nA which even using battery power is insignificant.
    With this device I am getting a persistent 11 uA power draw in sleep.
    As usual I have put all the pins as output and turned them off (except the interrupt).
    I have tried to turn off everything else off including weak pullups yet it make no difference.

    Any ideas?

     
  • William Roth

    William Roth - 2015-05-11

    11uA suggests it is not entering (or staying) in sleep mode. What troubleshooting steps have you taken?.

    I think I would set the configuration to INTIO1, where there is a clock out signal. Then monitor the clock out pin with a scope and see if it tells you anyting. .

    I would also completely disconnect any external peripherals and write a simple test program to assure that the chip is in sleep mode. The configuration should make sure that the watchdog timer is disabled and the program should make sure that all internal peripherals are off. This should confirm that everything is correct to to get to the published 50 nA.

    ~8 uA might suggest that the 32Khz oscillator is still running. If not then possibly an external peripheral is sinking current somehow.

     

    Last edit: William Roth 2015-05-11
  • David Stephenson

    Finally found the problem. The following is needed before to go into low power sleep mode (and return). Now it is using 450 nA as indicated in the datasheet.
    VREGPM=1
    SLEEP
    NOP
    VREGPM=0
    wait 100 ms

    I was under the impression that this was only needed when operating at 5V - clearly not.

     
  • Anobium

    Anobium - 2015-05-21

    Well done. If you post a complete working example I would like to publish as an example.

    Anobium

     
  • David Stephenson

    This is the routine it uses a normally open push button to switch off the device (or at least put it in a state where the battery life is >100 years).
    There is the slight advantage that data in RAM is retained (no need to use the EEPROM).

    on interrupt extint0 call wakeup 'put this anywhere
    'sets interrupt pin usually portb.0 as interrupt
    
    'interrupt pin should be pulled to ground (100k)
    'and go positive when activated
    'MCLRE should be off and pulled high (10k)
    'Watchdog timer should be off
    'Brownout should be inactive
    
    if kint=1 then 'shutdown if interrupt flag set
    dir porta.0 out
    dir porta.4 out 'change all input pins to output
    dir porta.5 out
    porta=b'00000000'
    portc=b'00000000' 'set all pins off
    portd=b'00000000' 'turns off all peripherals
    portb=b'00000000'
    set porte.0 off
    set porte.1 off
    set porte.2 off
    vregpm=1 'go into low power mode
    sleep
    nop 'dummy line after sleep
    nop 'let's make sure
    nop
    vregpm=0 'come out of low power
    wait 100 ms 'needs time to settle
    
    're-initialize peripherals here
    
    dir porta.0 in
    dir porta.4 in 'set inputs back to input
    dir porta.5 in
    wait 250 ms
    kint=0 'reset interrupt flag
    end if
    
    sub wakeup
    kint=kint+1 'flag for interrupt
    if kint>1 then kint=0
    wait 250 ms
    return
    end sub
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.