View previous topic :: View next topic |
Author |
Message |
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
Watchdog reset |
Posted: Mon May 13, 2024 5:00 pm |
|
|
Compiler: 5.026
Hi guys,
Just a quick question, is there a way to know what part of the code causes a watchdog reset to occurre, A little bit like that piece of code that can tell you where an address strap or stack error occurred.
Thanks!
Ben |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon May 13, 2024 6:48 pm |
|
|
hmm, something tells me maybe BUT my gut says a WDT reset 'should' start the program 'from the beginning' ,which should be a 'clean slate'.
It's one of those have to read the datasheet for your PIC...might be a special feature ??
you could code like the POST cards for PC did. set a counter,display the number do an 'operation or test', next..... When the POST card 'stopped' , it was the PREVIOUS test that failed. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue May 14, 2024 8:44 am |
|
|
No, as Jay says, this is a full reset.
Also a watchdog will not repeatedly happen at one location. The watchdog
timer is quite inaccurate, and so exactly the same watchdog may/will
trigger at lots of different instructions.
Calculate the minimum watchdog time for your chip. Then use something like
the MPLAB simulator to count instructions. When it gets to the count for
the watchdog, every location after this could have it trigger. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue May 14, 2024 11:28 pm |
|
|
As a comment to this the normal way to track where you are in a program,
is to 'cheat'. Assuming you chip has a spare UART, set this up to a fast
baud rate, and link the output to a USB serial adapter running one of
the standard terminal programs. Then at key points in your code, add
a simple putc, sending marker bytes. Using a hardware UART, the code
time needed by this is tiny. So when it watchdogs, you will have a list
of bytes, suddenly jumping back to the start of code one. The last byte
before the jump back, will be the marker at the start of the code section
you need to look at. |
|
|
|