WDT

30 views
Skip to first unread message

Zet Weeh

unread,
Dec 1, 2019, 1:57:59 AM12/1/19
to jallib
LS

I can't find the difference between:

'WDTCON_SWDTEN = off' and 'pragma target WDT control'. 

I searched on Internet but I could not find the answer.
I hope someone will explain.

Kind regards
Peter 

RobJ

unread,
Dec 1, 2019, 2:04:55 AM12/1/19
to jallib
Hi Zet,

I am not sure but I think it could be the following. The pragma normally controls the 'fuses' of the PIC so they are not changeable anymore since the fuses are programmed when you program the PIC. In your case of the WDT you could 'fuse' the WDT during programming but apparently there is still a way to change the operation in software.

But maybe somebody has a better explanation. This is the one I could think off.

Kind regards,

Rob

PuceBaboon

unread,
Dec 1, 2019, 6:47:43 PM12/1/19
to jallib
Zet,

   It's not available on all processors and perhaps the most important thing to note is that the CONTROL setting makes the watchdog available whether the hardware fuse is set or not.  The SWDTEN calls are the actual switch-on and switch-off of the WDT when software control is enabled.

   As an example, it' s useful for waking processors from deep sleep, although the implementation will vary from processor to processor.  The attached file is one I use for a project which had an 18F master with a couple of 12F1840 slaves.  The timer is set to give a (roughly) one second sleep between watchdog interrupts.  Note the different pragma for the watchdog timer pre-scaler for the two different chip types.

            -John-
watchdog_sleep.jal

Zet Weeh

unread,
Dec 2, 2019, 5:43:59 AM12/2/19
to jallib


Op zondag 1 december 2019 07:57:59 UTC+1 schreef Zet Weeh:
LS

Wauw, I got a lot of answers also by mail and some with examples.
I learned a lot about WDT.
I understood that 'pragma target WDT    Disabled ' gives an error because it's already standard in tthe PIC-lib 18F4455 I use.
Thanks for your help.

Peter
Heiloo

Rob CJ

unread,
Dec 2, 2019, 1:11:54 PM12/2/19
to jallib
Hi Peter,

That is not completely correct. The pragma is not always the same for every PIC. I you look at the blink sample you find:
pragma target WDT      CONTROL                   -- watchdog

That is because the options given in the device file 16f4455 for WDT are:
pragma fuse_def WDT:3  0x1 {       -- Watchdog Timer Enable bit
       ENABLED = 0x1                     -- WDT enabled​
       CONTROL = 0x0                     -- WDT disabled (control is placed on the SWDTEN bit)​
       }​

So you have to check the device file if you really want to know which settings to use for which pragma (and what the default is, in this case 0x1 so ENABLED) or you can have a look at the blink sample for your PIC, that is often the easiest way to get the right pragmas for your application.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Zet Weeh <zet....@gmail.com>
Verzonden: maandag 2 december 2019 11:43
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] Re: WDT
 
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/70c02f88-1f1a-40d0-bed6-c60ea8940e35%40googlegroups.com.

Ptr

unread,
Dec 3, 2019, 2:59:20 PM12/3/19
to jal...@googlegroups.com

Hi Rob

 

I already looked in the library and understood 0x1 = enabled.

I did not understand

pragma fuse_def WDT:3  0x1

but that’s less important because I then knew how to handle.

 

Kind regards,

Peter

 

 

Van: Rob CJ
Verzonden: maandag 2 december 2019 19:11
Aan: jallib
Onderwerp: Re: [jallib] Re: WDT

 

Hi Peter,

 

That is not completely correct. The pragma is not always the same for every PIC. I you look at the blink sample you find:

pragma target WDT      CONTROL                   -- watchdog

That is because the options given in the device file 16f4455 for WDT are:

pragma fuse_def WDT:3  0x1 {       -- Watchdog Timer Enable bit

       ENABLED = 0x1                     -- WDT enabled​

       CONTROL = 0x0                     -- WDT disabled (control is placed on the SWDTEN bit)​

       }​

 

So you have to check the device file if you really want to know which settings to use for which pragma (and what the default is, in this case 0x1 so ENABLED) or you can have a look at the blink sample for your PIC, that is often the easiest way to get the right pragmas for your application.

 

Kind regards,


Rob

 

Reply all
Reply to author
Forward
0 new messages