no, and it will be in low current consumption.
BTW, who'll know that if you set the SLEEP to it's maximum and do a loop... few usec in hours in not low consumption...
Code:GoodNight: SLEEP 65535 goto GoodNight
no, and it will be in low current consumption.
BTW, who'll know that if you set the SLEEP to it's maximum and do a loop... few usec in hours in not low consumption...
Code:GoodNight: SLEEP 65535 goto GoodNight
Last edited by mister_e; - 19th January 2006 at 02:10.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Permanent Sleep eh?.... Well apart from a Sledge Hammer... try...
@ SLEEP
The PIC will sleep PERMANENTLY until woken by an interrupt event... this does not mean you have to embed Assembler interrupts or the like, execution of the program 'should' continue from the next instruction when the PIC is woken from it's slumber.
For example this snippet of code shows (for a 16F628) what Registers you need to set in order to trigger a wake event...
You can see that I'm setting a wake-up call using either RB0 or PortB inputs. The Pause can be omitted, but works for me, so that the PIC can have a stretch, yawn, light-up a cigarette etc...Code:' ' PIC Low-Power Sleep Routine ' --------------------------- ' ' Set Sleep Interrupts ' -------------------- INTCON=%00011000 ' Interrupt Control Register ' 7=0 - GIE - Global Interrupt Enable ' 6=0 - PEIE - Peripheral Interrupt Enable ' 5=0 - TOIE - TMR0 Overflow Interrupt Enable ' 4=1 - INTE - RB0/INT Enable ' 3=1 - RBIE - PORTB change interrupt Enable ' 2=0 - TOIF - TMR0 Overflow Flag ' 1-0 - INTF - RB0/Ext Interrupt Flag ' 0=0 - RBIF - PORTB Interrupt Flag OPTION_REG.6=1 ' 1=RB0 Rising-Edge Trigger, 0=Falling-Edge Trigger ' ' Reset Interrupt Flags ' --------------------- INTCON.1=0 ' Reset RB0 Flag INTCON.0=0 ' Reset PORTB change Flag ' ' Sleep ' ----- @ SLEEP Pause 100 ' Needed for system Wake-Up
Hello Mel,
I am trying to get this sleep comand to work and it simply does not work.
my code:
@ DEVICE PIC16F628A, INTRC_OSC_NOCLKOUT, WDT_OFF, LVP_OFF, PWRT_OFF, PROTECT_OFF, BOD_OFF
CMCON=7
VRCON=%01101100 'VRCON bit7 is OFF for no current drain
OPTION_REG.7 = 0 ' ENABLE INTERNAL PULLUPS
Trisa = %01111111
Trisb = %11111111
LED VAR PORTA.7
'
' PIC Low-Power Sleep Routine
' ---------------------------
'
' Set Sleep Interrupts
' --------------------
INTCON=%00011000 ' Interrupt Control Register
' 7=0 - GIE - Global Interrupt Enable
' 6=0 - PEIE - Peripheral Interrupt Enable
' 5=0 - TOIE - TMR0 Overflow Interrupt Enable
' 4=1 - INTE - RB0/INT Enable
' 3=1 - RBIE - PORTB change interrupt Enable
' 2=0 - TOIF - TMR0 Overflow Flag
' 1-0 - INTF - RB0/Ext Interrupt Flag
' 0=0 - RBIF - PORTB Interrupt Flag
OPTION_REG.6=1 ' 1=RB0 Rising-Edge Trigger, 0=Falling-Edge Trigger
CYCLE:
'
' Reset Interrupt Flags
' ---------------------
INTCON.1=0 ' Reset RB0 Flag
INTCON.0=0 ' Reset PORTB change Flag
'
' Sleep
' -----
LOW LED
@ SLEEP
@ nop
@ nop
@ nop
@ nop
Pause 100 ' Needed for system Wake-Up
HIGH LED : PAUSE 200 : LOW LED
GOTO CYCLE
Maybe I could be missing some thing. The LED just keeps blinking.
Basically I am trying to incorporate this in a garage code lock project.
any help ?
Last edited by Acetronics2; - 12th May 2007 at 13:34.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
You are obviously being woken from Sleep, so find out what is causing it...
...and ground all the INPUT pins on PortB in case one is floating.
Heuuu
No GIE = No Sleep ( RTFDatasheet ... $ 14.8.1 - Greyed Note ), so we set GIE Bit
Then ... Executes the 1St NOP
Then ... Branches to location 0004 ...
But there is a supposed Interrupt stubb here instead of falling into the "program" ...
a single " DEFINE INTHAND INIT " without any interrupt stubb ( LOL ! ) would push the libs away from the 4 first program locations ... and allow restarting the PIC as a first power up ...
We could also Branch to the "Pause 100" ... to have some visual effect before re-entering sleep ... ( wich is better ...I think)
Sooo ...
we add :
DEFINE INTHAND _BLINK ' near top of program
and
BLINK:
Before
Pause 100 ' Needed for system Wake-Up
HIGH LED : PAUSE 200 : LOW LED
GOTO CYCLE
I am right, Mel ???
Alain
PS: We are aboard PBC list ... what about interrupts in PBC ???
Last edited by Acetronics2; - 12th May 2007 at 15:14. Reason: PBC or PBP used ???
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
"Super Acetronics" - I think he might be right. He should change his name to Supertronics![]()
Bookmarks