PDA

View Full Version : Power Saving on 16f628



andybarrett1
- 4th October 2020, 20:00
Hi All

Thank you for putting up with me

My recent Bluetooth project is sitting on a 12v Battery ... I am now looking to save some valuable Ah ...

Suggestions as to how are welcome

Changes in the __Config maybe ?

Pulling unused inputs to Ov maybe?

project is currently working fine 👍

Just need to save battery where I can

Andy

peterdeco1
- 5th October 2020, 09:24
Just my 2 cents here. On most of my 16F819 projects idling current is about 5mA. When I add NAP 0, it drops to 1/2 mA. I put it at the top of the program where it's waiting for something such as a button press.

richard
- 6th October 2020, 04:46
wake on serial input example, you would need to add code to eliminate floating inputs and disable unused "modules" to get the
absolute minimum power use.


this wakes on any serial input and goes back to sleep if an "A" is not received



;16f628a #CONFIG
__config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _BODEN_ON & _LVP_OFF & DATA_CP_OFF & _CP_OFF
#ENDCONFIG
include "dt_ints-14.bas"


DEFINE OSC 8


RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 12 ' 9600 Baud @ 8MHz, 0.16%
asm
INT_LIST macro
INT_HANDLER RX_INT , _RX, asm,NO
endm
INT_CREATE
ENDASM


wsave var byte $20 system
wsave1 var byte $a0 system ; If device has RAM in bank1
wsave2 var byte $120 system ; If device has RAM in bank2


LED VAR PORTB.7
TRISB=%01111111 'Make RB0 input
BUFF var byte
FLAG var byte
CMCON=7
FLAG=0
LED=1
PAUSE 500
HSEROUT["READY",13,10]
@ int_enable RX_INT


Main:
LED=0
@ SLEEP
LED=1
IF (FLAG) THEN
GOSUB somewhere
ENDIF
PAUSE 50
Goto Main
Somewhere:
HSEROUT["I got an A", 13,10]
FLAG=0
RETURN




RX:
asm
MOVLW "A"
BANKSEL RCREG
SUBWF RCREG,W
BTFSS STATUS,Z
GOTO EXT
BANKSEL _FLAG
BSF _FLAG,0
EXT
BANKSEL 0
INT_RETURN
endasm

andybarrett1
- 6th October 2020, 09:05
wake on serial input example, you would need to add code to eliminate floating inputs and disable unused "modules" to get the
absolute minimum power use.


this wakes on any serial input and goes back to sleep if an "A" is not received



;16f628a #CONFIG
__config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _BODEN_ON & _LVP_OFF & DATA_CP_OFF & _CP_OFF
#ENDCONFIG





All good help thank you will try ..... Just re:- Above.... I have done the same but turned BODEN_OFF

All works ok ... And does give me a little saving

BR
Andy

andybarrett1
- 6th October 2020, 09:06
Thank You


All good help thank you

Andy