evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
PIC 16f877a sleep |
Posted: Thu Apr 15, 2010 6:09 am |
|
|
Hi,
I need to use sleep mode for PIC 16f877a for particular time and have to wake up the microcontroller after 5 seconds. Which commands can be used for these actions? Can you help me?
thanks,
Varadharaj.E _________________ embedding innovation in engineers |
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Thu Apr 15, 2010 10:03 am |
|
|
No instructions.
To give a time, requires an external oscillator (A RTC chip, with an alarm output for example). The PIC itself, does not have this ability.
The 'nearest' you can get, is first to use Timer1, running with a watch crystal between C0, and C1, disable T1SYNC, and you can then get an interrupt after a maximum of 65536 cycles of this (typically 2 seconds, with a 32768Hz crystal), Do this twice, then set the timer 'on' to 32768 counts, and the next interrupt will be after only one second, giving the five seconds required. So the chip will have actually woken three times, but for such a short duration, that the power consumption will be miniscule.
So the 'minimum' solution would be to add such a crystal, and use this ability, but with the downside that the chip will wake three times.
Other possible solution without hardware, is the watchdog, but this is terribly inaccuracte. It's 'nominal' time period is 18mSec, but this varies from 7mSec to 33mSec. Using the maximum prescaler (/128), gives a nominal 2.3 seconds, but this varies between chips, temperature, and power voltage, down to 0.896 seconds, and up to up to 4.2 seconds. Repeating the time twice to get close to 5 seconds, will give times from under 2 seconds, up to over 8 seconds...
So if you want an accurate 5 second timeout, best choice, is to add an externall RTC, with a programmable alarm, and set this to give 5 seconds.
Best Wishes |
|