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

WDT_FROM_SLEEP

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



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

WDT_FROM_SLEEP
PostPosted: Tue Mar 11, 2014 12:07 pm     Reply with quote

I am getting the above reset cause in a project of mine. The name of this reset cause seems to be total nonsense. The chip I am using (PIC18F25J11) does not reset because of a WDT while sleeping - it wakes up. There is a separate reset cause for an actual WDT timeout. I have specifically disabled the WDT while code is executing (it is disabled immediately after waking up and set immediately before sleeping). The data sheet for this chip does not seem to shed any light on the situation as there doesn't seem to be anything other than a general watchdog reset as a reset reason. This is not a random reset, I can make it happen every time in a certain place in my code. It would seem to be an error in the code but the amount of code to make this happen is too large to post.

I suppose what I really need to know, if someone knows, is what on Earth is WDT_FROM_SLEEP? It is never explained anywhere. I have found multiple people ask this question on the internet and nobody seems to ever really explain it. What causes this reset reason and why does it not even seem to be a valid reset reason according to the chip docs?

EDIT: BTW, this is with the 4.129 compiler
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

PostPosted: Tue Mar 11, 2014 12:55 pm     Reply with quote

Slight follow up: I looked at the ASM list and traced down what it was doing. Upon doing so it became apparent that it really does basically list the actual value of RCON. And, so, I see that a value of 3 for RCON really does mean that it was in sleep mode (PD is set 0) and that the watchdog overflowed (TO is also 0). The question is, why wouldn't this cause a wake up like it is supposed to instead of a reset? I then suspected it was going into deep sleep or otherwise not sleeping quite like I wanted. But, I called sleep() and the ASM code for that function does seem to do the right thing. Now I'm really stumped.

I suppose in my application it really isn't the end of the world that it resets but it annoys me that a reset would happen when I didn't ask it to.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 11, 2014 1:16 pm     Reply with quote

Quote:
If the device is not executing code (all Idle modes and
Sleep mode), the time-out will result in an exit from the
power-managed mode
(see Section 4.2 “Run
Modes” and Section 4.3 “Sleep Mode”). If the device
is executing code (all Run modes), the time-out will
result in a WDT Reset (see Section 26.2 “Watchdog
Timer (WDT)”)


Look at this section of the 18F25J11.h file:
Code:
// Constants for calls to sleep() are:
#define SLEEP_FULL       0  // Default
#define SLEEP_IDLE       1  // Clock and peripherals don't stop


On the other hand,
http://www.ccsinfo.com/forum/viewtopic.php?t=49545
I didn't investigate this yet. If you can't determine the cause I'll install
your version and do that. Let me know.
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

PostPosted: Fri Mar 14, 2014 9:58 am     Reply with quote

I believe I've fixed the program with my program. In my case it seems like maybe I had messed up some coding by accidentally doing some unsafe things in an interrupt handler and also by accidentally mixing up calls to delay_ms and delay_us. Those two functions are orders of magnitude different but only one letter off.

Anyway, I don't have resets any longer. I still find the actual situation odd - the watchdog should never reset the MCU while in sleep mode. It is supposed to wake up the MCU. But, I have to wonder if a mess up related to an interrupt handler might be able to corrupt memory badly enough to cause such a thing to happen.
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