View previous topic :: View next topic |
Author |
Message |
miketwo
Joined: 04 Aug 2010 Posts: 24
|
RESTART_CAUSE() gives a number not in the device header |
Posted: Wed Aug 04, 2010 6:46 pm |
|
|
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
|
|
Posted: Thu Aug 05, 2010 9:15 am |
|
|
I don't think, that restart_cause() works correctly with PCD.
You may want to read RCON directly.
|
|
|
miketwo
Joined: 04 Aug 2010 Posts: 24
|
|
Posted: Thu Aug 05, 2010 12:52 pm |
|
|
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
|
|
Posted: Fri Aug 06, 2010 2:42 am |
|
|
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
|
Found it! |
Posted: Fri Aug 06, 2010 6:01 pm |
|
|
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
|
|
Posted: Sat Aug 07, 2010 8:00 am |
|
|
Did you actually observe a reboot? Or just a jump to an unexpected location?
The difference would reveal when debugging the code. |
|
|
|