16F628A current high during sleep


Closed Thread
Results 1 to 6 of 6
  1. #1
    Rubicon's Avatar
    Rubicon Guest

    Default 16F628A current high during sleep

    Hello,

    I have a problem that I'm unfortunately unable to solve on my own.

    16F628A with 4MHz Xtal and battery consumption is important.

    With Timer1 running I have it set to go straight to a sleep subroutine upon startup with an IF/THEN cycle count compare and @sleep. When an interrupt occurs every 0.5 seconds it goes to the interrupt service routine, updates the cycle count and interrupt timing then back to sleep or every third cycle to the main program where it completes checks within the 0.5 seconds and goes back to the sleep subroutine. If the checks fail then it goes to a shutdown subroutine using the END command.

    The thing is that during sleep I measure a current consumption of 1.2mA
    while after shutdown it's 0.4mA - the current consumption of the voltage regulator. All the TRISA/PORTA/TRISB/PORTB settings are the same in both the sleep and the shutdown subroutines with voltage comparators turned off and a VRCON bit7 OFF for no current drain. I can't figure out why there's the difference in current.

    Going through the archive I tried using a wire to ground through a resistor on the pins to observe the current, measuring the voltage on the pins directly, changing the old pic with a new one, altering TRISA/PORTA/TRISB/PORTB, removing Brown-out detect and all manner of other things to no avail. With older code I've now accidently overwritten that used no Timer1 or interrupts just an inaccurate overall cycle count it was 0.4mA during sleep. Taking practically everything out of the new code and making it just sleep imer1 and interrupts to see if it was them causing it it's still 1.2mA during the sleep cycle.

    The only possible clue I have due to a small voltage on the Xtal pins is that the oscillator is still running when it should, I think, be off and using the watchdog timer. Actually pulling the Xtal out when in sleep reduces the current consumption to 0.5mA.

    Even when reduced down to the code below it's still 1.2mA during sleep.

    DEFINE OSC 4
    @ DEVICE PIC16F628A
    @ DEVICE PIC16F628A,XT_OSC
    @ DEVICE PIC16F628A,WDT_ON
    @ DEVICE PIC16F628A,PWRT_ON
    @ DEVICE PIC16F628A,MCLR_ON
    @ DEVICE PIC16F628A,BOD_OFF
    @ DEVICE PIC16F628A,LVP_OFF
    @ DEVICE PIC16F628A,CPD_OFF
    @ DEVICE PIC16F628A,PROTECT_OFF


    ' HARDWARE
    CMCON = 7 'Disable comparators
    VRCON=%01101100 'VRCON bit7 is OFF for no current drain
    TRISA = %10011
    PORTA = 0
    TRISB = %01000101
    PORTB = %10000000 'PORTB outputs LOW but RB7 for it's wired directly to 555 trigger pin requiring a high to stop from triggering.

    SOUND PORTA.3, [120,10]

    CYCLE:
    CMCON=7
    VRCON=%01101100 'VRCON bit7 is OFF for no current drain
    TRISA = %10011
    PORTA = 0
    TRISB = %01000101
    PORTB = %10000000
    @SLEEP 'ASM Sleep
    GOTO CYCLE

    Any help here is greatly appreciated.

    Regards,

    Rubicon.

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    You will need to check if your port pins are going to the inactive state for any peripherals connected to them. for eg: if you have a transistor base via a resistor connected to a port pin, you will need to put this transistor off; ie: try to minimize all the external world drives. A schematic will help to clear this part. Otherwise, sleep should take the current around 40uA.

    Jerson

  3. #3
    Rubicon's Avatar
    Rubicon Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply and the advice.

    I don't have a schematic as yet as it's all breadboarded and constantly changing as I learn new things. I really must do one though.

    One thing I don't understand is why with the exact same port settings and commands @SLEEP is 1.2mA and END is 0.4mA. Shouldn't they be the same, either both 1.2mA or both 0.4mA?

    CYCLE:
    CMCON=7
    VRCON=%01101100 'VRCON bit7 is OFF for no current drain
    TRISA = %10011
    PORTA = 0
    TRISB = %01000101
    PORTB = %10000000
    @SLEEP 'ASM Sleep
    GOTO CYCLE

    SHUTDOWN:
    CMCON=7
    VRCON=%01101100 'VRCON bit7 is OFF for no current drain
    TRISA = %10011
    PORTA = 0
    TRISB = %01000101
    PORTB = %10000000
    END

    Regards,

    Rubicon.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    I am not sure if you have seen this.

    Excerpt from the datasheet of PIC16F917. I am sure this applies to the 628 too though I have not checked it.

    <Quote>
    When the SLEEP instruction is being executed, the next
    instruction (PC + 1) is pre-fetched. For the device to
    wake-up through an interrupt event, the corresponding
    interrupt enable bit must be set (enabled). Wake-up is
    regardless of the state of the GIE bit. If the GIE bit is
    clear (disabled), the device continues execution at the
    instruction after the SLEEP instruction. If the GIE bit is
    set (enabled), the device executes the instruction after
    the SLEEP instruction, then branches to the interrupt
    address (0004h). In cases where the execution of the
    instruction following SLEEP is not desirable, the user
    should have a NOP after the SLEEP instruction.
    </quote>

    Perhaps, you need to take care of this

    Like this
    @ sleep
    @ nop
    @ nop

    I use this for my 628 programs and get the sleep operate correctly.

    Jerson

  5. #5
    Rubicon's Avatar
    Rubicon Guest


    Did you find this post helpful? Yes | No

    Default

    Yes I admit to seeing that in the 16F628 datasheet and I tried a single nop without the @ after the sleep command without success. I'll put in what you suggest and see what happens today.

    Thanks,

    Rubicon.

  6. #6
    Rubicon's Avatar
    Rubicon Guest


    Did you find this post helpful? Yes | No

    Default

    Well that didn't work nor did trying it without the @. Back to looking at the pin states and doing a schematic.

    Thanks for your help here. I do appreciate it.

    Regards,

    Rubicon.

Similar Threads

  1. SERIN MIDI out of Synch?
    By jncortes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th June 2009, 20:08
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. Using Sleep
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th August 2008, 04:05
  4. sample code for M25P32
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th January 2007, 02:37
  5. 16F628A sleep current
    By David Marks in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th February 2005, 15:12

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts