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 CCS Technical Support

Can not change WDT prescale at run-time

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



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

Can not change WDT prescale at run-time
PostPosted: Tue Jun 07, 2016 8:28 am     Reply with quote

Code:
#include <18F25K22.h>
#device ADC=10

#FUSES WDT                      //Watch Dog Timer
#FUSES WDT_SW   
......
void main()
{  setup_wdt (WDT_2S);


I'm geting error 109 "Can not change WDT prescale at run-time" when calling setup_wdt(WDT_2S).
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 07, 2016 11:37 am     Reply with quote

Always post your CCS compiler version. I compiled your test program
with compiler vs. 5.059 and it compiled without errors or warnings:
Quote:

Executing: "C:\Program files\Picc\CCSC.exe" +FH "PCH_Test.c" +DF +LY -T -A +M -Z +Y=9 +EA #__18F25K22=TRUE
Memory usage: ROM=0% RAM=0% - 0%
0 Errors, 0 Warnings.
Build Successful.
Loaded C:\Program Files\PICC\Projects\PCH_Test\PCH_Test.cof.
BUILD SUCCEEDED: Tue Jun 07 10:35:48 2016

Test program:
Code:

#include <18F25K22.h>
#device ADC=10

#FUSES WDT                     
#FUSES WDT_SW   

void main()


setup_wdt (WDT_2S);

}
40inD



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

PostPosted: Tue Jun 07, 2016 12:09 pm     Reply with quote

my version is 5.019
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 07, 2016 12:20 pm     Reply with quote

I installed PCH vs. 5.019 and I still get Build Succeeded, no warnings and
no errors. Same test program.

Did you test it with my exact posted test program ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed Jun 08, 2016 12:49 am     Reply with quote

Classic possibility.
Is he possibly either building in debug mode, or in MPLAB (which defaults to building in debug mode)?.

If you try to run in debug mode, the wdt is disabled. The debugger cannot simulate the watchdog. Trying to change the watchdog in this case may well error.

Other possibility. He might have the processor include file for an older compiler. The V4 compilers, only have WDT_ON, and WDT_OFF supported for this chip. No time settings.
If he built originally with an older compiler, and the 'project' still has the properties set to use the older compiler's files, then it won't know about the option to change times....
shalts



Joined: 20 Oct 2006
Posts: 17
Location: Ankara

View user's profile Send private message Send e-mail

about the same error
PostPosted: Wed May 01, 2019 1:45 am     Reply with quote

I am receiving the same error message.

My complier version is 5.026.
Header is:
Code:

#include <18F26K22.h>
#use delay(internal=16000000,restart_wdt)
#fuses NOMCLR,NOPROTECT,noPUT,noBROWNOUT,NODEBUG
#FUSES WDT
#FUSES WDT_SW


for the main() I tried,
Code:

setup_wdt(WDT_OFF);
setup_WDT(WDT_64S);
setup_wdt(WDT_ON);


and this too
Code:
setup_WDT(WDT_64S);

I get the same error message at both cases. But when I try
Code:
setup_WDT(WDT_16);

it compiles without error. I noticed it might be giving errors when I use with "S" letter . Because I tried WDT_1S, WDT_8S, all gave me errors.

Any ideas that can help me ?

Thanks

Shalt
_________________
Murat Shalt Unal
shalts



Joined: 20 Oct 2006
Posts: 17
Location: Ankara

View user's profile Send private message Send e-mail

about the same error
PostPosted: Wed May 01, 2019 2:12 am     Reply with quote

Oooh .. I think I have missed the WDT4, WDT16 etc. parts at the #fuses .

I am going to study on WDT more Smile
_________________
Murat Shalt Unal
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed May 01, 2019 2:30 am     Reply with quote

As a comment though, you don't actually want:

#FUSES WDT
#FUSES WDT_SW

These both set the same pair of fuse bits.

You should just be using:

#FUSES WDT_SW

If you read the data sheet, you will see that these settings are both
trying to control the two bits WDTEN in CONFIG2H. There are four
options for the two bits here:

11 = WDT enabled in hardware; SWDTEN bit disabled
This is 'WDT'

10 = WDT controlled by the SWDTEN bit
This is WDT_SW

01 = WDT enabled when device is active, disabled when device is in Sleep; SWDTEN bit disabled
This is WDT_NOSLEEP

00 = WDT disabled in hardware; SWDTEN bit disabled
This is NOWDT

So if you select 'WDT', the watchdog can't then be controlled in software.
If you want it controlled in software, you need to be selecting WDT_SW
_only_.

The later compilers ignore the incompatible first line. Suggests yours may
not be doing this.
shalts



Joined: 20 Oct 2006
Posts: 17
Location: Ankara

View user's profile Send private message Send e-mail

PostPosted: Wed May 01, 2019 12:41 pm     Reply with quote

Mr. Ttelmah, Thank you so much for your explanations. I will be studying and trying on the problem tomorrow early morning.

Which line do you mean by first line at "The later compilers ignore the incompatible first line. Suggests yours may not be doing this."
_________________
Murat Shalt Unal
shalts



Joined: 20 Oct 2006
Posts: 17
Location: Ankara

View user's profile Send private message Send e-mail

solved
PostPosted: Thu May 02, 2019 12:34 am     Reply with quote

I 've got it solved.

at fuses I used #FUSES WDT8192 , and down at the main part erased the line "setup_wdt(32S)".

Then I put a test code under main()
Code:

while(1)
   {
      output_toggle(led1);
      sleep();
   }

I found out led1 toggles at 4mS * 8192 = 32,768mS

Thank you Mr. Ttelmah, once again the importance of reading datasheet well realized.
_________________
Murat Shalt Unal
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