View previous topic :: View next topic |
Author |
Message |
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
Can not change WDT prescale at run-time |
Posted: Tue Jun 07, 2016 8:28 am |
|
|
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
|
|
Posted: Tue Jun 07, 2016 11:37 am |
|
|
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
|
|
Posted: Tue Jun 07, 2016 12:09 pm |
|
|
my version is 5.019 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 07, 2016 12:20 pm |
|
|
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: 19513
|
|
Posted: Wed Jun 08, 2016 12:49 am |
|
|
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
|
about the same error |
Posted: Wed May 01, 2019 1:45 am |
|
|
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
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
|
about the same error |
Posted: Wed May 01, 2019 2:12 am |
|
|
Oooh .. I think I have missed the WDT4, WDT16 etc. parts at the #fuses .
I am going to study on WDT more _________________ Murat Shalt Unal |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Wed May 01, 2019 2:30 am |
|
|
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
|
|
Posted: Wed May 01, 2019 12:41 pm |
|
|
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
|
solved |
Posted: Thu May 02, 2019 12:34 am |
|
|
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 |
|
|
|