View previous topic :: View next topic |
Author |
Message |
tgilbert
Joined: 14 Aug 2020 Posts: 8
|
Program fails to execute when the watchdog timer is enabled |
Posted: Fri Aug 14, 2020 9:52 am |
|
|
Compiler - CCS C compiler V5.075
MPLAB version - 5.30
PIC 16F15323
Hey all,
I'm having problems getting a program to work when the watchdog timer restart_wdt() command is called. It works OK when the watchdog timer is not enabled. It also works when running MPLAB debug, even with the watchdog enabled.
Program execution fails as soon as restart_wdt is executed. I've tried many setup_wdt options and running without the pickit attached. No luck.
Below is a program to show what's happening. If the while(TRUE) loop executes without the restart_wdt statement then it works, but if the restart_wdt is included then it stops executing.
I've searched the forum discussions but did not find an answer. I figure I'm doing something stupid. Any suggestions?
Thanks,
Tim
Code: |
#include <16F15323.h>
/*********************** fuses *****************************************/
#FUSES WDT // Watch Dog Timer enabled
//#FUSES NOWDT // Watch Dog Timer disabled
#FUSES HS // Crystal osc > 4mhz
#use delay(clock = 20mhz)
#use fast_io(ALL) // fast io on all ports
void main()
{
set_tris_c(0b00000000);
output_low(PIN_C4);
setup_wdt(WDT_1S);
// while(TRUE) {output_toggle(PIN_C4); delay_ms(50);}
while(TRUE) {output_toggle(PIN_C4); delay_ms(50); restart_wdt();}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 14, 2020 10:09 am |
|
|
The CCS manual says:
Quote: |
setup_wdt() -
For PCH parts and PCM parts with software controlled WDT, setup_wdt( )
would enable/disable watchdog timer only if NOWDT fuse is set.
If WDT fuse is set, watchdog timer is always enabled.
|
You have the wrong fuse set. Change your fuse. |
|
|
tgilbert
Joined: 14 Aug 2020 Posts: 8
|
|
Posted: Fri Aug 14, 2020 10:46 am |
|
|
OK, I tried that and made a working test program. I'm still confused but I think I can go forward from here.
Thanks for you help, PCM programmer!
Tim |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Aug 14, 2020 12:08 pm |
|
|
Early (original..) PICs only had a hardware WDT, so the 'fuse' either enabled or disabled it during the programming (burning) of the PIC..
Today, some PICs (you'll have to check whicj ones !!) have a controllable WDT, where your program can actually enable/disable the WDT peripheral.
I know reading 700-800 pages of datasheet can be boring but it's 'details' like this that is the reason you need to read, yawn, 700+ pages.....
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Fri Aug 14, 2020 12:56 pm |
|
|
However the key point is the one made by PCM, that in a lot of cases,
'software' control of the watchdog, is only available when it is disabled in
the fuses. A few PIC's have three fuses here, WDT, NOWDT, and WDT_SW,
but by far the largest group have it so the watchdog can only be software
controlled when the hardware fuse is off.... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Aug 14, 2020 2:13 pm |
|
|
yeesh.. they're TOO darn complicated today !!!! Let's go back to 'windowed' PICs !! Life (and programming) was far simpler....
Jay |
|
|
|