5.5.23 · D1 · HinglishEmbedded Systems & Real-Time Software

FoundationsWatchdog timers — purpose, feeding, types

2,115 words10 min read↑ Read in English

5.5.23 · D1 · Coding › Embedded Systems & Real-Time Software › Watchdog timers — purpose, feeding, types

Watchdog code ki ek bhi line padhne se pehle, ya timeout formula mein numbers daalne se pehle, tumhe karib ek dozen chhote ideas apne andar utaarne honge. Parent note the watchdog topic maanta hai ki tum pehle se jaante ho ki "counter", "clock", "prescaler", aur "reset" kya hote hain. Yeh page in sabko ek-ek karke, ek-dusre pe depend karne ke order mein, bilkul scratch se banata hai — taaki jab ya jaisa koi symbol dikhe, tum pehle se jaante ho ki woh kis picture ki taraf point kar raha hai.


1. Clock — woh heartbeat jo sab kuch chalati hai

Socho ek piano student ke liye metronome: tick… tick… tick… bilkul even spacing pe. Chip mein exactly yahi hota hai, bas millions ticks per second.

Figure — Watchdog timers — purpose, feeding, types

Ek clock ko describe karne wala akela number hai uski frequency.

Topic ko yeh kyun chahiye: watchdog ek clock se drive hota hai. Watchdog ka counter kitni tezi se badalta hai, yeh poori tarah is se set hota hai. Parent formula mein yeh ke roop mein aata hai — specifically watchdog ko feed karne wali clock ki frequency (jo, jaise hum dekhenge, CPU ki clock se often alag, independent clock hoti hai — dekho Hardware Timer Peripherals).


2. Counter — track karna ki kitne ticks guzar gaye

Socho ek numbered dial jisse clock har tick pe ek notch nudge karta hai. Akela chhoda jaaye toh ek down-counter steadily zero ki taraf slide karta rehta hai.

Figure — Watchdog timers — purpose, feeding, types

Topic ko yeh kyun chahiye: woh jagah hai jahan ek fresh watchdog counter count down karne se pehle start karta hai. Watchdog ko "feed" karna matlab hai counter ko wapas pe slam karna. Jitna bada , utna lamba zero tak ka slide, isliye yeh seedha set karta hai ki reset se pehle tumhare paas kitna time hai.

Recall

kyun hota hai, kyun nahi? Kyunki counting se shuru hoti hai. bits distinct values ( se tak) dete hain, isliye sabse bada single value se ek kam hota hai. ::: 16 bits ke saath: distinct values, top value .


3. Prescaler — clock ko purpose se slow karna

Yahan ek problem hai. Chip ki clock millions baar per second tick karti hai. Ek 16-bit counter sirf tak rakh sakta hai. Full speed pe yeh ek tiny fraction of a second mein zero pe count down ho jaata — itna fast ki useful na ho. Humein counter ko slower tick karaane ka tarika chahiye.

Socho ek turnstile jo sirf har 64ve aadmi par khulta hai: crowd (fast clock) jaldi aati hai, lekin room (counter) dheere bharta hai.

Figure — Watchdog timers — purpose, feeding, types

Topic ko yeh kyun chahiye: prescaler tuning knob hai. Yeh exactly parent ke timeout formula mein prescaler hai. Chhota → fast counting → short timeout (fast recovery lekin false resets ka risk). Bada → slow counting → long timeout (slow operations ke liye tolerant). Watchdog timeout choose karna matlab hai choose karna.


4. Feeding — woh kaam jo tumhe zinda rakhta hai

Socho ek boulder ko, jo slowly ek cliff (zero) ki taraf roll kar raha hai, wapas pahaad par push karna. Jab tak tum kaafi baar baar push karte raho, woh kabhi roll off nahi hoga.

Topic ko yeh kyun chahiye: feeding tumhare software aur watchdog ke beech poori interaction hai. Parent mein "feeding strategies" aur "feeding too early / too late" ki saari discussion is ek kaam ke baare mein hai — ki tumhare program mein kab yeh instruction perform karte ho.


5. Reset aur Interrupt — zero pe kya hota hai

Topic ko yeh kyun chahiye: "zero pe pahunchna → reset ya interrupt" watchdog ke existence ka poora point hai. Yeh samjhe bina ki reset actually ek running program ke saath kya karta hai, "it resets the system" ka koi matlab nahi.


6. Timeout period aur feasibility window

Topic ko yeh kyun chahiye: yeh teen symbols "Window Watchdog" section ki poori vocabulary hain. bas woh time hai jab tumhara code feed instruction actually call karta hai, last feed se measure karke.


7. "Independent clock" kyun matter karta hai — failure ki kahani

Yahi wajah hai ki parent "separate clock source" par zor deta hai — aur kyun ek watchdog ek genuine Safe State Design tool hai, sirf ek fancy timer nahi.


Prerequisite map

Clock ticks steadily

Frequency f in hertz

One tick lasts 1 over f

Counter changes by 1 per tick

Down-counter slides to zero

Bits give N_max the top value

Prescaler P divides the clock

Time per step P over f_clock

Timeout N_max times step time

Feeding reloads counter to N_max

Reach zero triggers reset or interrupt

Watchdog Timer topic

Isse bottom-up padho: clock aur bits milke ek counting counter banate hain, prescaler uski speed set karta hai, isse timeout milta hai, feeding usse reset karta hai, aur zero pe pahunchna reset fire karta hai — yahi watchdog hai.


Equipment checklist

Cover the right side and answer each before moving to the parent note.

Clock ki frequency kya measure karta hai, aur uska unit kya hai?
Ek second mein kitne cycles (ticks) hote hain; hertz (Hz) mein measure hota hai.
Agar ek clock Hz pe chalti hai, toh ek tick kitni lambi hoti hai?
seconds — frequency ka reciprocal.
Up-counter aur down-counter mein kya fark hai?
Up-counter har tick pe 1 add karta hai; down-counter har tick pe 1 subtract karta hai. Watchdog ek down-counter hota hai.
Ek -bit counter ke liye kya hai aur kyun?
; counting 0 se shuru hoti hai, isliye distinct values ka top value se ek kam hota hai.
Prescaler counter tak pahunchne wali clock ke saath kya karta hai?
Yeh usse divide karta hai: har ticks mein se sirf 1 pass hoti hai, isliye aur har step seconds leta hai.
Hum timeout paane ke liye ko se kyun multiply karte hain?
se 0 tak slide karne mein steps lagte hain, har ek tak chalta hai; inhe stack karne se milta hai.
Watchdog ko "feed" karna physically kya karta hai?
Ek special register value likhta hai jo down-counter ko wapas par reload kar deta hai, ek aur poora timeout khareed deta hai.
Jab counter zero pe pahunchta hai toh kya hota hai?
Watchdog ek system reset trigger karta hai (ya pehle ek interrupt), software ko restart karta hai.
Ek achha hardware watchdog apni alag clock kyun use karta hai?
Taaki agar main CPU clock fail ho jaaye, watchdog apni independent clock pe count karta rahe aur phir bhi reset force kar sake.
Window watchdog mein feed kab valid hoti hai?
Sirf jab ho — na bahut jaldi aur na bahut deri se.