there's not much in your circuit than should be drawing power when 'off'.
1. change the 1k on pin4 ra3 to 47k
2. use TRIO=$FF when you want to turn off stuff completely
3. have you considered running the chip slower?
-- you can use 125khz and use "9600 baud serial" out to give you "real" 300 baud
--my usb>serial won't work on 75baud otherwise I'd use 32khz for debugging
Code:
'low speed osccon 31khz
'bit 6-4 IRCF<2:0>: Internal Oscillator Frequency Select bits
' correction
' by shifting
' |
' v Min Pause times
' 111 =8MHz
' 110 =4MHz (default) 0
' 101 =2MHz 1 2
' 100 =1MHz 2 4
' 011 =500kHz 3 8
' 010 =250kHz 4 16
' 001 =125kHz 5 32
' 000 =31kHz (LFINTOSC) 7 128
OSCCON.6 = 0
OSCCON.5 = 0
OSCCON.4 = 1
speed_shift con 5 ' use 0-7 : oscillator / delay correction by shifting
' PAUSE is affect by this, see the above minimum pause times
'
' FOR LOW POWER DISABLE AS MANY FEATURES AS POSSIBLE.
' ** FOR 12F675 un-COMMENT CMCON=7, ANSEL=0, ADCON0=0
' ** FOR 12f683 un-COMMENT CMCON0=7, ANSEL=0, ADCON0=0
' ** FOR 12F629 COMMENT ALL
' CMCON = $07 '12F675 CMCON — COMPARATOR CONTROL REGISTER ALL DIGITAL
CMCON0 = $07 '12F683 CMCON0 — COMPARATOR CONTROL REGISTER ALL DIGITAL
' TRISIO = %11111011 'SET TO ALL OUTPUTS 1=INPUT
' ADCON1 = %01100000 ' Set a2d convert at clk/6 [slowest]
' ADCON1 = %00000000 ' Set a2d convert at clk/2 [fastest]
ANSEL = %00000000 ' AN0/RA0 as analog input 1=ANALOG
' ADCON0 = %00000001 ' .7=10bits left justify result!! / .0 1=a2d ON
ADCON0 = %00000000 ' .7=10bits left justify result!! / .0 1=a2d ON
' WPUA = %00000000 ' TURN ON WEAK PULLUP 1=ON VALID=.5.4.2.1.0
'constants
ALL_INPUTS CON $FF ' Set to all inputs to save power
LAMP_OFF CON $00
LAMP_ALL con $36 'GPIO.1.2.4.5
'IO assignments
SERIAL_PIN var GPIO.2
Main code snippets:
Code:
X= 250 ' DELAY TIME in milliseconds
led = lamp
gosub Lamp_ON
' turn OFF LED time = 750mS
X= 750 : gosub OFF_Lamp
those called subroutines
Code:
' Speed affected by the CPU clock speed
Lamp_ON:
TRISIO = ALL_INPUTS - led
GPIO = led
Pause X >> speed_shift ' Delay for on time in milliseconds
TRISIO = ALL_INPUTS ' Set to all inputs to save power
Return
OFF_Lamp:
TRISIO = ALL_INPUTS
Pause X >> speed_shift ' Delay for on time in milliseconds
Return
' *** SLEEP & NAP Speed *NOT* affected by the CPU clock speed
' NAP uses slow clock mS 0=18,1=36,2=72,3=144,4=288,5=576,6=1.52s,7=2.304s
ON_Lamp_Short:
TRISIO = ALL_INPUTS - LAMP
GPIO = LAMP
NAP x
TRISIO = ALL_INPUTS ' Set to all inputs to save power
Return
OFF_Lamp_Short:
TRISIO = ALL_INPUTS ' Set to all inputs to save power
NAP x
Return
Bookmarks