View previous topic :: View next topic |
Author |
Message |
kloppy
Joined: 28 Jul 2004 Posts: 32
|
reset cause |
Posted: Mon Oct 04, 2004 5:11 am |
|
|
hi
i have a program that works quite well. but sometimes it resets the processor (not regularly). i don't use the wdt(!) and the mclr pin is high all the time.
what else can cause a reset???
i use a 16f876 with PCM 3.206 |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Mon Oct 04, 2004 5:18 am |
|
|
Do you have a stable power supply? How many stack levels are you using?
Use the fucntion restart_cause() to identify the reason for the resets:
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.
Availability: All devices
Requires Constants are defined in the devices .h file. |
|
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Mon Oct 04, 2004 5:20 am |
|
|
Depending on the PIC. It could be software or hardware. For software it could be a stack overflow. This can be caused by too many nested calls or by recursive calls. Another common problem is where an interrupt handler changes a register and does not restore it before exiting the handler - dependig on where the mainline code was at the time of the interrupt, the alignment of the planets etc, this sort of problem could appear to occur very rarely but in fact could also be corrupting otherwise sensible data
For hardware it may be noise on the power supply.
Moral of the story - if you need it to be reliable use a WDT!! A software WDT (as in the PIC18F) is better than no WDT at all. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 04, 2004 1:39 pm |
|
|
Quote: | What else can cause a reset??? |
1. Brownout reset. Is your Vdd voltage always at level which
is safely above the brownout voltage ?
2. Stack overflow, because of too many stack levels used, due to
using the #separate statement without keeping an eye on the
stack usage. Stack usage is listed at the top of the .LST file.
See my post at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=20422
This shows how you can exceed the maximum number of
stack levels when you use #separate. This will cause your
program to crash when it executes a certain sequence of code. |
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Tue Oct 05, 2004 11:32 am |
|
|
ok thanks very much it was a stack overflow!! |
|
|
|