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 support@ccsinfo.com

RESTART_CAUSE() gives a number not in the device header

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



Joined: 04 Aug 2010
Posts: 24

View user's profile Send private message

RESTART_CAUSE() gives a number not in the device header
PostPosted: Wed Aug 04, 2010 6:46 pm     Reply with quote

When I poll restart_cause(), it gives me back 16. However, in the device header file there is no 16 -- the highest is 15 which is a trap conflict.

First, versions of everything:
Compiler -- PCD 4.109
MPLAB -- 8.53.00.00
MPLAB Plug-in -- 2.0.0.12
MPICD3 -- 1.0.3.21

I'm programming to a PIC24FJ256GA110.

I can't quite figure out where the error is yet. It's not always repeatable but I think it's a compiler issue with indexing or sizing a struct whose fields land on odd memory locations. That's just a guess though. I was hoping this question has an easy answer that might point me in the right direction.

Cheers,
Michael
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Aug 05, 2010 9:15 am     Reply with quote

I don't think, that restart_cause() works correctly with PCD.
You may want to read RCON directly.
Code:
#word RCON = 0x740
miketwo



Joined: 04 Aug 2010
Posts: 24

View user's profile Send private message

PostPosted: Thu Aug 05, 2010 12:52 pm     Reply with quote

Thanks. I did that and it seems to work. I get a bizarre reset -- none of the bits are set except for the 5th one -- SWDTEN: Software Enable/Disable of WDT bit.

I'm guessing restart_cause() is as confused as I am over this. Weird.

Thanks though! That helped a bunch!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Aug 06, 2010 2:42 am     Reply with quote

I noticed, that you are also using ICD3. Why don't simply check the RCON state after the restart, before it's modified by the C startup code.
miketwo



Joined: 04 Aug 2010
Posts: 24

View user's profile Send private message

Found it!
PostPosted: Fri Aug 06, 2010 6:01 pm     Reply with quote

I'm still not sure how the PIC manages to reboot without setting one of the RCON bits, but I found the problem that causes it -- it's kind of crazy. I'll post it here in case anyone else gets a weird restart_cause().

In some autocoded library I was including, there was the following function call
Code:

mth_vect_norm(&mth_vect_norm_12_u, &mth_vect_norm_12_y, &                           
       mth_vect_norm_12_i);


The error is pretty obvious. I don't know why the autocoder put 3 tabs and a carriage return between the '&' and the variable, but it did. It compiled without complaint, but went into the "Undocumented Reboot" when it ran. God only knows what it was trying to do instead of passing the variable. (I'd look at the assembly, but I'm just happy to be done with this bug...)

Thanks for the help!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Aug 07, 2010 8:00 am     Reply with quote

Did you actually observe a reboot? Or just a jump to an unexpected location?
The difference would reveal when debugging the code.
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