Hi Larry,
SHORTCIRCUIT wrote:Where does the MX clear come from? Is it a standard C function so that all who know how to program C would then know to apply the MX_CLEAR_WATCHDOG;? Or does it come from somewhere else?
I could be wrong, so happy to be corrected.
I believe it's not standadard C function.
Since boostC and HiTec (now XC) use different commands to clear WDT, I believed Matrix created
function that will work with compilers used so far.
SHORTCIRCUIT wrote:How do I set the watchdog period?
You will need to look in the datasheet on page 142.
It shows the WDTCON which is WATCHDOG CONTROL REGISTER.
The setting of those bits determine Watchdog Timer Period from 1/32 to 1/65536
Basically there is a 16bit timer and a 7bit counter shared with Timer0
So you can use anyone or both.
As the watchdog uses a 32KHz internal oscillator = 1/32E03 = 32E-06 duration.
Looking at the datasheet the minimum time just with WATCHDOG CONTROL REGISTER = 32E-06 x 32 = 1ms. The latter 32 is just with WDTCON (bits 1 - 4 ) set to 0000.
With bits 1 - 4 set to 1111 for maximum time of 32E-06 x 65536 = 2.1 seconds.
If you also use the 7bit prescaler (OPTION_REG BITS 0 TO 2) as well, then maximum time before watchdog triggers: 32E-06 x 65536 x 128 = 268.4 seconds.
I believe I have calculated correctly.
So to set the watch dog timeout for maximum time duration and you're not using Timer0 prescaler.
With Flowcode6:
Use a C Code block with
Code: Select all
option_reg = option_reg|0b111;
wdtcon = wdtcon|10111;