View previous topic :: View next topic |
Author |
Message |
ringo
Joined: 10 Feb 2004 Posts: 8
|
Warm boot vs cold boot |
Posted: Tue Feb 10, 2004 2:45 pm |
|
|
Is there a way to tell on program startup if it is a warm boot or a cold boot. In other words can you tell if you just powered up the circuit or if the watchdog timer has casued a reboot?
I'm using a 16f877 if it matters.
Thanks
Ringo |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Tue Feb 10, 2004 2:56 pm |
|
|
Quote: | RESTART_CAUSE()
Syntax:
value = restart_cause()
Parameters:
None
Returns:
A value indicating the cause of the last processor reset. The actual values are device dependent. See the device .h file for specific values for a specific device. Some example values are: WDT_FROM_SLEEP, WDT_TIMEOUT, MCLR_FROM_SLEEP and NORMAL_POWER_UP.
Function:
This is a general purpose device reset. It will jump to location 0 on PCB and PCM parts and also reset the registers to power-up state on the PIC18XXX.
Availability:
All devices
Requires
Constants are defined in the devices .h file.
Examples:
switch ( restart_cause() ) {
case WDT_FROM_SLEEP:
case WDT_TIMEOUT:
handle_error();
}
Example Files:
ex_wdt.c
Also See:
restart_wdt(), reset_cpu()
|
|
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Feb 10, 2004 3:24 pm |
|
|
Restart_Cause() does not cause a restart, as Newtone's message implies. It is put near the beginning of main() to determine what the cause of the last restart was. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Tue Feb 10, 2004 3:57 pm |
|
|
My mistake I ripped that from the manual without reading it first. |
|
|
ringo
Joined: 10 Feb 2004 Posts: 8
|
|
Posted: Wed Feb 11, 2004 8:35 am |
|
|
Thanks, That's excactly what I need. I didn't know that function existed.
Ringo |
|
|
|