View Full Version : SLEEP, WDT and INT
xnihilo
- 27th March 2008, 08:13
Hello,
I would like to use the SLEEP command in my program.
The main program is a small loop like:
loop:
Sleep 5
GOTO loop
Because when an interrupt occurs, program jumps at the INT handler and the stuff is processed there.
My question is: I don't want to use WDT (which is a feature I don't understand anyway),
can I use sleep without having to enable or disable registers related to WDT ?
Thanks
mackrackit
- 27th March 2008, 08:26
Nap might be more of what you want.
From the manual
NAP puts the processor to sleep for one Watchdog Timer period. If the
Watchdog Timer is not enabled, the processor will sleep forever or until
an enabled interrupt or reset is received
Turn the WDT off in the config and the PIC should be in a low power mode until the interrupt occurs.
xnihilo
- 27th March 2008, 17:55
From PBP pro manual:
Places the microcontroller into low power mode for short periods of time. During this NAP, power consumption is reduced to minimum. The listed periods are only approximate because the timing is derived from the Watchdog Timer which is R/C driven and can vary greatly from chip to chip and over temperature. Since NAP uses the Watchdog Timer, its timing is independent of the oscillator frequency.
It seems it needs WDT.
Moreover, the right way to use this, according to PBP, it's to define a period.
I don't want to use WDT and I don't want to set period. I would like to put the PIC into low power sleep until an int awakes it...
Darrel Taylor
- 27th March 2008, 18:43
Sure, just turn off the WDT in the configs.
Then when you put it to sleep, it will stay that way until an interrupt is triggered.
You can use ...
@ SLEEPand you won't need to enter a period.
<br>
xnihilo
- 27th March 2008, 23:00
Sure, just turn off the WDT in the configs.
Then when you put it to sleep, it will stay that way until an interrupt is triggered.
You can use ...
@ SLEEPand you won't need to enter a period.
<br>
Do I need to use
@ sleep
?
With PBP, can I use something like:
loop:
sleep
goto loop
?
(I always disable WDT in the config words).
mister_e
- 27th March 2008, 23:03
Yes you can do something like that... but the assembler line @ sleep will send your PIC in sleep mode forever... or 'till an interrupt happen. PBP SLEEP will send your PIC in sleep mode for a x period of time and then wake up. It's really up to you. I prefer the @ SLEEP
xnihilo
- 28th March 2008, 06:45
Yes you can do something like that... but the assembler line @ sleep will send your PIC in sleep mode forever... or 'till an interrupt happen. PBP SLEEP will send your PIC in sleep mode for a x period of time and then wake up. It's really up to you. I prefer the @ SLEEP
Thanks you all.
So I can use something like:
ON INTERRUPT GOTO myinthandler
start:
@ sleep
myinthandler:
...
In this case my main program is only the @sleep instruction and once the int has been processed, it goes back to sleep until next interrupt, is that right?
mackrackit
- 28th March 2008, 09:46
Yes, that should work.
This thread has some good info of the ins and outs
http://www.picbasic.co.uk/forum/showthread.php?t=3128&highlight=sleep
Read post #3
xnihilo
- 30th March 2008, 14:45
Thanks a lot!
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.