 |
 |
View previous topic :: View next topic |
Author |
Message |
scanan
Joined: 13 Aug 2004 Posts: 60 Location: Turkey
|
Watchdog timer and #ORG directive |
Posted: Mon May 06, 2013 2:55 am |
|
|
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: 19779
|
|
Posted: Mon May 06, 2013 3:53 am |
|
|
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: 60 Location: Turkey
|
|
Posted: Mon May 06, 2013 4:28 am |
|
|
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: 19779
|
|
Posted: Mon May 06, 2013 8:54 am |
|
|
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. |
|
 |
|
|
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
|