Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

watchdog timer question?

Status
Not open for further replies.

hassan1980

Full Member level 4
Joined
Jan 14, 2005
Messages
204
Helped
9
Reputation
18
Reaction score
6
Trophy points
1,298
Activity points
1,340
pic18 watchdog timer not reset

I have a question relating watchdog timer at PIC micros ?

if the watchdog timer overflow then the micro will go to reset vector address this is true then my question is :

when the Pic micro reset by watchdog timer are their pic registers reset or they stay keeping the last values before reset

another question if the watchdog timer reset the micro is there a way to back at the point that watchdog timer overflow or this is not available.
 

Watchdog reset mcu like when you put reset pin down to Vss, and up to Vdd.

1. So your registers will be reseted to default value.

2. No it is not possible.

Regards!

Mr.Cube
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
mrcube_ns said:
Watchdog reset mcu like when you put reset pin down to Vss, and up to Vdd.

1. So your registers will be reseted to default value.

2. No it is not possible.

Regards!

Mr.Cube

By the way, how to use watchdog timer if the timer0 is used.

Can you give me details about this?
 

Hi, Registers will be the same as before the reset !!!!!. No matter what people tell you !. All RAM will remain the same too !.

You can't return to the old position but you can use a WDT reset to leave sleep mode (sleep instruction) if you want and then you always know where you were !.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
PaulHolland said:
Hi, Registers will be the same as before the reset !!!!!. No matter what people tell you !. All RAM will remain the same too !.

You can't return to the old position but you can use a WDT reset to leave sleep mode (sleep instruction) if you want and then you always know where you were !.

can you put an example please?
 

(enable wdt !)

nop
nop
nop
(any type of code, loops etc..)
sleep
nop -> Code will resume when the wdt will execute (MCU will not reset !)
nop
nop
(any type of code, loops etc..)


hope this is clear !.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
I build a project as digital counter then I am using Timer0 interrupt for scannig two Seven Segments my question is ?

How to use watchdog timer with this situation
 

Hi, Maybe I do not understand what you want or expect from the watchdog timer but the watchdog timer is used to prevent your code from ending-up in an endless loop. So normally you use a watchdog timer to reset your system if the code is hanging in an endless loop due to wrong input of a crash due to power supply or clock failure.

You can also use a watchdog timer to do something for you, wake you up, or other things when you are a sleep or want to execute some code some times a second or even a few times a minute.

What you want ?. Its not clear to me :)..
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
PaulHolland said:
Hi, Maybe I do not understand what you want or expect from the watchdog timer but the watchdog timer is used to prevent your code from ending-up in an endless loop. So normally you use a watchdog timer to reset your system if the code is hanging in an endless loop due to wrong input of a crash due to power supply or clock failure.

You can also use a watchdog timer to do something for you, wake you up, or other things when you are a sleep or want to execute some code some times a second or even a few times a minute.

What you want ?. Its not clear to me :)..

Actually, I know the uses for watchdog timer, but how to use watchdog timer if I am using interuppt for timer0?

that's all
 

If your using a watchdog timer and timer 0 or any other interrupt source I would not clear the WDT during the interrupt (so also during TIMER0). Only call and clear your WDT during your main loop and set the WDT so that it can always clear your WDT again within the time.

Normally your code has some endless loop, performing all kind of tasks and checking all kind of things, only clear WDT during this loop !!.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
I don't use the PIC micros, but I'm curious about the register preservation that PaulHolland mentioned. If all registers are preserved through the watchdog reset does this include the stack pointer as well? If so, then one could recover their previous location, either subroutine level or pre-planned location, from the watchdog reset by utilizing the stack pointer. Yes?
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
johnyaya said:
I don't use the PIC micros, but I'm curious about the register preservation that PaulHolland mentioned. If all registers are preserved through the watchdog reset does this include the stack pointer as well? If so, then one could recover their previous location, either subroutine level or pre-planned location, from the watchdog reset by utilizing the stack pointer. Yes?

Hi, All registers are preserved but the problem is that on PIC micro's you can't access the stack pointer nor the stack itself (atleast on PIC16 and below, on PIC18 you can access the saved value but not the pointer :).

So the answer is NO !. unfortunately.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
Watchdog timer wont reset registers.
there is no option in controller to start back from where it reset.you have to implement that somehow in software.
PIC use seperate time for watchdog.only the prescalar is shared between watchdog and timer.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
PaulHolland said:
If your using a watchdog timer and timer 0 or any other interrupt source I would not clear the WDT during the interrupt (so also during TIMER0). Only call and clear your WDT during your main loop and set the WDT so that it can always clear your WDT again within the time.

Normally your code has some endless loop, performing all kind of tasks and checking all kind of things, only clear WDT during this loop !!.

Please be specific.

this is an example :

Start: ;equ registers and inti the other one

inturrupt: ;Interrupt routine for timer0

Main: ;this is the main program
goto main ;Loop forever


the question is how to use WDT if I am using interrupt with Timer0?

hope this to be clear
 

Which PIC are you using ??.. What language ?. C or ASM ??.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
PaulHolland said:
Which PIC are you using ??.. What language ?. C or ASM ??.

I am using 16F630

and the language I use is picbasic
 

The last time I used BASIC was in 1983 :).... Begin..... End. Can I do an example in asm ?.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
Hi,
Basically the need for a Watch Dog Timer arises because the controller has gone out of control and need to be put back to a known state. When the CPU has already lost its sanity, there is no point in depending upon the contents of the registers, as the CPU would have already messed it around before the WD reset could bring it back to a known initial state. So, generally the Watch Dog output is ORed with Power-on Reset and applied to CPU and therefore it should have the same effect.
Now regarding the location of the Watch Dog clearing routine, it is better to keep it in the Main program, instead of being in an interrupt routine, since the interrupt being event based, it may still work alright if the CPU did not corrupt the ISR instructions and keeps looping elsewhere. We have to keep calling this routine, within the interval required to overflow the WD Counter.
Regards,
Laktronics
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
I'm not real familiar with PICbasic, but I've read in a different forum:
WDT is handled automatically for you by PBP in background - you don't have to do anything. If you look at the Assembler listing of any of your compiled programs, you will see a liberal sprinkling of CLRWDT instructions throughout. PBP puts them there to keep resetting the WDT so you don't have to.

The Pause instruction compiles to have a CLRWDT within it, otherwise something like Pause 10000 would cause the WDT to restart the PIC.

You would have to try real hard to get the WDT to crash a PBP program through normal code execution...

I also see that you can disable the automatically generated watchdog reset code:
You can add the following define to stop PBP from automatically resetting the WDT (see PICBasic Pro Manual under CLEARWDT command)...

DEFINE NO_CLRWDT 1

If you disable the auto reset then you will need to do it yourself.

The above quotes were taken from https://www.picbasic.co.uk/forum/archive/index.php/t-172.html

Hope this helps.
 

    hassan1980

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top