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

Program fails to execute when the watchdog timer is enabled

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



Joined: 14 Aug 2020
Posts: 8

View user's profile Send private message

Program fails to execute when the watchdog timer is enabled
PostPosted: Fri Aug 14, 2020 9:52 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 14, 2020 10:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 14, 2020 10:46 am     Reply with quote

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: 9105
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Aug 14, 2020 12:08 pm     Reply with quote

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: 19219

View user's profile Send private message

PostPosted: Fri Aug 14, 2020 12:56 pm     Reply with quote

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: 9105
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Aug 14, 2020 2:13 pm     Reply with quote

yeesh.. they're TOO darn complicated today !!!! Let's go back to 'windowed' PICs !! Life (and programming) was far simpler....

Jay
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