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

Watchdog timer and #ORG directive

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



Joined: 13 Aug 2004
Posts: 58
Location: Turkey

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

Watchdog timer and #ORG directive
PostPosted: Mon May 06, 2013 2:55 am     Reply with quote

Hi everybody,
I would like to know
when the watchdog timer is overflown where the program restart.
Does the program restart from the #ORG defined address?

thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19255

View user's profile Send private message

PostPosted: Mon May 06, 2013 3:53 am     Reply with quote

Restart, is always a hardware jump to the restart location (address zero for most PIC's).
If you have your 'main' code located somewhere with an #ORG (and always if interrupts are enabled), the instruction at this location, will be a jump to the start of the main code. So, 'no', it does not go directly to the #org location (the hardware does not support this), but it goes there as soon as it can.

Best Wishes
scanan



Joined: 13 Aug 2004
Posts: 58
Location: Turkey

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

PostPosted: Mon May 06, 2013 4:28 am     Reply with quote

Ttelmah wrote:
Restart, is always a hardware jump to the restart location (address zero for most PIC's).
If you have your 'main' code located somewhere with an #ORG (and always if interrupts are enabled), the instruction at this location, will be a jump to the start of the main code. So, 'no', it does not go directly to the #org location (the hardware does not support this), but it goes there as soon as it can.

Best Wishes

As I understand if interrupt are enabled like timers or serial communication,
the start point will be next to where the WDT timer overflow?
Its a big issue for my project because when the WDT overflow the program should restart as nothing happened.
cheers
Ttelmah



Joined: 11 Mar 2010
Posts: 19255

View user's profile Send private message

PostPosted: Mon May 06, 2013 8:54 am     Reply with quote

Reset is always to address 0. Nowhere else (ignoring more complex PIC's).
The point about interrupts is that _they_ always call an address in low memory (depends on the PIC model), normally 0x8, and 0x18 on a PIC18. Since their handler code _must_ be at this address, if these exist, the main PIC code cannot be put at the bottom of memory, so the compiler puts this after the interrupt handlers, and puts a jump at address 0 to the start of the main code.
Seriously, _read the data sheet_. What the watchdog reset does is described here. It is exactly the same as the normal power on reset, except certain flags are set to say 'this was a watchdog reset'. These flags are what the function 'restart_cause' returns, so you can write your code to behave differently if you want.
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