benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
|
Posted: Thu Feb 22, 2018 6:57 am |
|
|
UPDATE:
An explanation from CCS support:
-------------------------------------
The only ways that it should be able to return 16 for restart_cause() is if it was called twice in software, or if something caused the program to jump to a point that caused restart_cause() get called again without it being an actual reset of the device. A call to goto_address(0); is an example of how the second way could occur. I would check that you don't have multiple calls to restart_cause() in your code, one example that I've personally run into is that I had a call to restart_cause() in a standalone bootloader and then call it again in my application.
-------------------------------------
I looked in my code and the only two places I call restart_cause() is at the beginning of the main():
Code: | void main()
{
delay_ms( 250 );
// Enable watchdog timer
setup_wdt( WDT_16S | WDT_ON );
// Get MCU's internal last restart cause
Error.InternalRestartCode = restart_cause();
// rest of code here
} |
...and after the delay_cycles(100) following sleep( SLEEP_FULL ):
Code: | // Sleep NOW
sleep( SLEEP_FULL );
// Wake-up from sleep
delay_cycles(100);
// Get MCU's internal last restart cause
Error.InternalRestartCode = restart_cause(); |
I'll post more if CCS replies to this.
Benoit |
|