Watchdog timer on 16F628A

Status
Not open for further replies.

kcn

New Member
In my project, I have the following segment of code:

Code:
wait
		btfss	PORTA, 0		;wait for button
		goto	wait			;if it is high, break out of loop

The only thing is that the button may never be pressed by
the user, and I want to be able to break out of this loop.

How do I use the watchdog timer exactly? I can't understand
the data sheet! The above code is executed after some other
code and basically, I want to require the user to press a
button within 1 second or so (which is within the abilities of the
watchdog timer for the 16F628A), if the button isn't pressed,
I'd like for execution to jump to a function that I define.

Is there extremely simple sample code for using the
watchdog timer that somebody could point me to?

Thank you.

kcn
 
The watchdog timer is intended to help prevent the processor accidently entering an endless loop - it's not for doing this!.

The obvious way to do it is to only check for a keypress a certain number of times - say 250 times (as it only requires a single GPR as a counter), with a 4mS delay between each test. This will give roughly a one second period in order to press a key.
 
Watchdog timer??
Can it perform as a countdown timer?
BTW, what is a GPR? Pls explain more on this. If I were to have a delay of 1Hour, do I need to set the GPR as 900k times? I'm talking of doing a feedback input on something regularly every an hour.
Pls advise, thanks!
 
You can't use it as normal Timer.It's only function is to reset the PIC if you don't call CLRWDT instruction before it expires. GPR stands for General purpose register, means that you can use it for anything.
Use TIMER1 timer in 16bit mode and it will overrun every 65ms (@4Mhz).
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…