Sleep function?

Discussion in 'Embedded Systems and Microcontrollers' started by tarts, Aug 9, 2009.

  1. tarts

    Thread Starter New Member

    May 27, 2009
    9
    0
    Hello
    I want to use a sleep function on a PIC12f629 cause I'm placing it into a digital camera. It has to save power when camera is off so it won't drain the battery.

    Almost all the pins are configured as inputs(tri-state) and they will go active Low when a certain signal is received from rc receiver. So the PIC will activate shutter, zoom in, zoom out, on/off functions.

    Now what happens if I go sleep mode, all outputs that are configured as inputs will go active Low. It means that all the leds on my breadboard lihts up and all functions would be executed in the camera.

    How can I do so that the pins remain tri-state while sleep? Manual says nothing about this phenomen:confused:
     
  2. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    I/O pins are not effected or changed when you enter sleep mode, input pins remain high impedance, output pins that were high before entering sleep mode remain high and outputs that were low remain low.

    Going into sleep mode simply turns off the clock oscillator.
     
  3. tarts

    Thread Starter New Member

    May 27, 2009
    9
    0
    May it be that I have afaulty PIC or something? Cause I can't see anything wrong with my code.
    I also set up all pins to input just before sleep instruction, but still all LEDs light up and fade if waked up again.
     
  4. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    Its difficult to know what is going on without seeing your circuit or code, one thought that comes to mind though is you say you set all pins as inputs before entering sleep.
    Do you have pull-ups/pulldowns on your pins or are they just left floating?
    If you leave input pins floating you will get all sorts of unpredictable results.
     
  5. tarts

    Thread Starter New Member

    May 27, 2009
    9
    0
    I found a mistake. Instead of setting all pins to output I xor-ed them:D so I just chanhed the state.

    But the floating. yes the manual says that I should pull them hi or low externally to avoid floating and save energy.
    Can't I do it internally? Pins are connected to camera switches and I have no idea where they are connected inside the camera.Manual also mentions on-chip pull-ups.

    If I set WPU(weak pull up) registers for input pins does it help? Is it the same thing as "on-chip pull-ups" mentioned in sleep section?
     
  6. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    Turning on weak pull-ups will work fine.
     
  7. tarts

    Thread Starter New Member

    May 27, 2009
    9
    0
    Thanks dude
    I got my current in sleep mode from 90uA to 50uA. WPU really helps
     
  8. tarts

    Thread Starter New Member

    May 27, 2009
    9
    0
    Manual says that standby current is 2nA:eek:
    How is that possible?
    Is there any way I can decrease the current? 50uA is still a little too much. Camera itself uses about 30uA when switched off. Now adding 50 is all togethar 80uA which is a little too much.
    If I could get to 10-20uA then it would be great too.
     
  9. KL7AJ

    AAC Fanatic!

    Nov 4, 2008
    2,039
    287
    I activate my sleep function by forgetting my morning coffee. :)
     
  10. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    Are the 'weak pull ups' fighting any external circuitry?

    Unused pins can be set as inputs and directly grounded, inputs should have definite pull-up (or pull down) resistors and outputs should be set so whatever they drive is not drawing current.
    Tristate may not be a good idea, depending on the load.

    To minimise external leakage, you can run external pullup resistors (for input switches etc) from an output pin, then set that pin Low before sleeping.

    Also make sure all internal peripherals are correctly configured, eg. turn off the ADC if you are not using it and so on. (Work all the way through the peripheral list for the chip you are using).

    ps. Some peripherals may cause the clock to stay active so can have a drastic effect on sleep power.
     
Loading...