CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

reset cause

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kloppy



Joined: 28 Jul 2004
Posts: 32

View user's profile Send private message

reset cause
PostPosted: Mon Oct 04, 2004 5:11 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 5:18 am     Reply with quote

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: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Oct 04, 2004 5:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 1:39 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 11:32 am     Reply with quote

ok thanks very much it was a stack overflow!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group