Using Watchdog in 12F675

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Using Watchdog in 12F675

Post by Benj »

I need to use watchdog for 12F675 in project that is used outdoor with no one to to reset the MCU if it stop working.

Cannot manage to find any documentation on Flowcode V3 and this Forum about the usage.

Please help me on the usage in Flowcode V3.

Thanks in advance.

TanLS

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using Watchdog in 12F675

Post by Benj »

Hello,

To allow the watchdog to work you should simply have to enable it in the chip -> configuration menu.

Then every so often if your program you will need to call the C function.

clear_wdt();

User avatar
tanlipseong
Posts: 31
Joined: Thu Aug 27, 2009 3:11 pm
Location: Malaysia
Contact:

Re: Using Watchdog in 12F675

Post by tanlipseong »

Thanks a lot Benj,

If i am using 4Mhz internal oscillator and let everything else default in Flowcode V3, how long before the watchdog reset occur?


Thanks in advance.
TanLS

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using Watchdog in 12F675

Post by Benj »

Hello,

It depends on what is the value of the prescaler.

You can change the prescaler by writing to the option register using C code.

Basically the formula would look like this.

max time period = 1 / ( clockspeed / 4 / prescaler / 256 )

User avatar
tanlipseong
Posts: 31
Joined: Thu Aug 27, 2009 3:11 pm
Location: Malaysia
Contact:

Re: Using Watchdog in 12F675

Post by tanlipseong »

Benj

With Clock speed =4Mhz, the max time period to clear_wdt() = 0.032Sec.
if i use delay in the program that longer then above value, the watchdog will reset the MCU right?

how to go about using delay of say 0.5sec to blink LED while able to clear the watchdog timer?
do i need to use nested loop or there are better way?

Please help.
Thanks in advance
TanLS

User avatar
tanlipseong
Posts: 31
Joined: Thu Aug 27, 2009 3:11 pm
Location: Malaysia
Contact:

Re: Using Watchdog in 12F675

Post by tanlipseong »

Benj,

Earlier when i search for "watchdog" it returns only 1 hit, (that was during the time i can not post new topic).

now i do a search for "watchdog" it returns 170 hit. (and i found many info from there).

anyway thanks for helping.

Tq
TanLS

Post Reply