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.