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

PIC24E restart_cause() returns unknown cause 16 (0x10)

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



Joined: 30 Oct 2007
Posts: 276
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PIC24E restart_cause() returns unknown cause 16 (0x10)
PostPosted: Fri Dec 15, 2017 9:42 am     Reply with quote

Compiler: 5.026
Device: PIC24EP512GP806

In the device header file, these are the listed cause values for <restart_cause()>:
Code:

#define RESTART_POWER_UP           0
#define RESTART_BROWNOUT           1
#define RESTART_WATCHDOG           4
#define RESTART_SOFTWARE           6
#define RESTART_MCLR               7
#define RESTART_ILLEGAL_OP        14
#define RESTART_TRAP_CONFLICT     15

In my code, the MCU goes to sleep after 1 minute. When it returns from sleep, the first thing I do is check the restart_cause() flag and it returns 16 (0x10). This is not listed in the device header file.

What can it be?

I'll check the MCU docs but in the meantime, if someone has a good answer, then it would be appreciated!

Thanks!

Ben
benoitstjean



Joined: 30 Oct 2007
Posts: 276
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Fri Dec 15, 2017 9:50 am     Reply with quote

So in the MCU docs <http://ww1.microchip.com/downloads/en/DeviceDoc/S8.pdf> register <Register 8-1: RCON: Reset Control Register>, it seems that restart cause 16 (0x10) is 'Watchdog Time-out Flag bit':

bit 4 WDTO: Watchdog Time-out Flag bit
1 = WDT time-out has occurred
0 = WDT time-out has not occurred

But the unit did not wake-up via a WDT timeout, it woke-up via an external interrupt on EXT 0 while it was sleeping.

So my question is why isn't it returning 0x80 instead since bit 3 is:

bit 3 SLEEP: Wake-up from Sleep Flag bit
1 = Device has been in Sleep mode
0 = Device has not been in Sleep mode

Thanks!

Ben
Ttelmah



Joined: 11 Mar 2010
Posts: 12514

View user's profile Send private message

PostPosted: Fri Dec 15, 2017 1:23 pm     Reply with quote

Restart_cause, only works at the start of the code, when the processor has 'restarted'. Calling it anywhere else, is not guaranteed to give a genuine reason.
It sounds as if you are calling it after the processor has waken from sleep, not 'restarted'.
benoitstjean



Joined: 30 Oct 2007
Posts: 276
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Fri Dec 15, 2017 1:25 pm     Reply with quote

Ohhh.... I see what you mean. Ok, I'll work something out.

Thanks.

Benoit
Ttelmah



Joined: 11 Mar 2010
Posts: 12514

View user's profile Send private message

PostPosted: Fri Dec 15, 2017 1:38 pm     Reply with quote

If you want to test the WDTO bit, just test it.
Code:

#BIT WDTO=getenv("BIT:WDTO")


     if (WDTO)   //will test the WDTO bit
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