Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Reducing Power Consumption on PIC16F628A in SLEEP mode

Status
Not open for further replies.
from your explanation above, I came to know that You know clearly what you want. Then, what you want more? First try with the logic one by one. If there is any difficulty then let me know.

do I use the watcdogtimer to do my 8 hour loops?

Yes. You must use watchdog (WDT) timer.
 

No, I don't, I'm trying to define it so you can help. :shock:
 

Have you got all the things (PIC MCU, Programmer, Bread Board, etc) ready on your hand now?
 

I have built the circuit on a bread board, have everything ready, but still waiting for the programmer.
In the mean time I am trying to write some code to start with once I have the programmer.
 

Once if the programmer is ready, inform me. Then only you can see the real time effect and can change the code according to your requirement.

In the mean time, you can google on this forum (or google entire web) or see the example code (Interrupt) provided at Hi-Tech C compiler (Program files\Hi-Tech-C\v9.80\samples\...), for sample code for PIC MCU and try to gather some basic informations like setting configuration words, How to set and use interrupts, setting watchdog timer (with/without pre-scaler), etc.
 

Done that, this is how far I am now:
list p=16F628A
radix hex

org
;Definitions
STATUS equ 03h ;Set status address
TRISB equ 86h ;Set TRISB address
PORTB equ 06h ;Set PORTB address
;Initialisation
bcf STATUS,0 ;Make sure we are in bank 0
clrf 01h ;Address of the other timer – TMR0
bsf STATUS,0 ;Switch to bank 1
movlw 1<<PSA | b'111' ;Set prescaler
option ;WDT period 2.3s
clrwdt ;Reset the WDT and prescaler
bcf STATUS,0 ;Come back to bank 0

bsf STATUS,5 ;Go to Bank 1
movlw b'00000101' ;Move 00000101 to w
movwf TRISB ;Move 00000101 to TRISB
bcf STATUS,5 ;Go back to Bank 0

;Main Program
while(1){
clrwdt ;Clear WatchdogTimer

delay_s(2)
sleep ;Enters sleep mode

---------- Post added at 22:55 ---------- Previous post was at 22:51 ----------

But my logic say I don't need to use interrupt with RB0 if I am going to wake up with watchdog every 2.3s? Then can just check the IO's every 2.3s?
I do not understand how to count up to 12522 (I need to trigger RB3 every 8hours(28,800s), with wdt of 2.3s I need to count loops till 12522).
 

But my logic say I don't need to use interrupt with RB0 if I am going to wake up with watchdog every 2.3s? Then can just check the IO's every 2.3s?

If you want save power, you have to use WDT. Enable Interrupt to check IO's.

I know little only on ASM. I can assist you on C only.
 

Yes, I want to save power, but WDT has max timeout of 2.3s, so will wakeup every 2.3s anyway. Then can sample IO's OR do I just set an interrupt on RB0 with a seperate routine?
 

set the counter. you can increment the counter on expiry of WDT (2.3 sec). Once counter reached specified time, say 8hrs (8hrs x 60 mins x 60 sec = 28800), off WDT and check IO's and enable WDT after processed and put back PIC in to Sleep.
 
Thank you, my eyes are square now from all the reading. Will continue in the morning.
 

I guess if you don't understand ASM then we are stuck, I've studied it now and too far down to go back now.
Wrote complete code in ASM, will look for different forum and help that can assist in ASM.
Thank you.
 

many person can assist you from this forum and also in microchip forum. You can use both forums to achieve your goal. But, pl be mind that no one will come and help you on basic things. they can help you to debug the error and flow of program, sample codes, etc. I am also ready to help but only in C. You can also refer sample codes that provided on MPLAB IDE.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top