View previous topic :: View next topic |
Author |
Message |
pyroboy123
Joined: 11 Mar 2004 Posts: 7
|
SLEEP ??? |
Posted: Mon Mar 15, 2004 9:13 am |
|
|
Hi all,
I have a question for you all.
I am trying desperately to get the SLEEP to work but I think I'm doing something wrong because it doesnt seem to work.
I'm trying to make my PIC do RTC using Timer1 and having the Timer1 have the PIC woken up. My code is as follows:
#int_timer1
void interrupt() {
adds seconds
}
void main() {
set up the interrupts
while(TRUE) {
make minutes/hours out of the counted seconds.
SLEEP
}
}
When I comment the SLEEP line, the programs works fine, it counts the seconds no problem. I can see this by having a LED change each second (which I do in the interrupt function).
I event tried having the SLEEP done once by "ifing" it. And once its down for SLEEP, it doesnt wake up from the timer1.
My PIC is the 16f87 which has timer1 wakeup built in.
Anyone ?
Thx |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 15, 2004 12:34 pm |
|
|
Timer1 must be running in asynchronous counter mode
to allow it to wake up the PIC from Sleep.
In other words, it needs an external oscillator or
crystal to be connected to pins T1OSI and T1OSO on the PIC.
See the data sheet, and also see the Timer1 reference manual:
http://www.microchip.com/1010/suppdoc/refernce/midrange/index.htm |
|
|
pyroboy123
Joined: 11 Mar 2004 Posts: 7
|
|
Posted: Mon Mar 15, 2004 1:57 pm |
|
|
Ok Thx I'll look into that...
but its a pain beause I thought I would try to keep the RB6/7 free for programming .... |
|
|
Sandman
Joined: 26 Jan 2004 Posts: 15 Location: Kiruna, Sweden
|
|
Posted: Mon Mar 22, 2004 3:58 am |
|
|
I have the same problem. Timer 1 will not work if I'm seting it to use an external oscillator(crystal). I have no solution to the problem, and no one has been able to help me.
If you find out how to set timer 1 to work with an external oscillator and use it to wake the PIC from sleep, I would be very pleased if you could let me know how you did it.
Good luck! |
|
|
|