MCU: MC9S12G128
Problem: COP watchdog works only in debug mode.
I'm trying to apply COP watchdog in my program. Below is what I did.
I Initialized the Bus Clock and COP Watchdog. And watchdog is not feeded in the main loop. I suppose there will be a reset in a second after the COP Watchdog initialization. But fact is it doesn't work this way. It doesn't reset. But while debugging, reset happens every time after the COP Watchdog initialization. Why? What did I miss?
In the Main.c
And in the Prm file
I'm glad you solved your problem Bloom You. I had a similar problem--worked in debug with breakpoints set but not with breakpoints turned off.
The mcu made it through my 5 ms loop code in about 1 msec in debugging mode with breakpoints set--but never made it through that loop at all when breakpoints were turned off (and interrupts were active and apparently utilizing every clock cycle of the mcu). When I put the watchdog reset in a frequently used interrupt, the WDOG worked as expected. Now to learn about KDS profiling tools and fix the problem.
Details: KDS V3.2, S9KEAZN64MU, Windows 7
Sorry Andrew, I saw your reply at the end of last September. And then something emergency happened to me. And days later, I forgot it.
Did you fix the problem?
Hi,
The data sheet states:
2. WCOP, CR2, CR1, CR0:
— Anytime in Special Mode, when WRTMASK is 0, otherwise it has no effect
— Write once in Normal Mode, when WRTMASK is 0, otherwise it has no effect.
– Writing CR[2:0] to “000” has no effect, but counts for the “write once” condition.
– Writing WCOP to “0” has no effect, but counts for the “write once” condition.
If you use bit writes (bit processing instructions) then the register is processed by read-modify-write process so the change of the only one bit writes to/ modifies entire byte.
In the case of write once registers (in normal mode) the access to second write is disabled. It is always strictly recommended to check whether you do not write to write once register more than once. (The issue usually appears if you use same automatic setup tools where you do not see directly what has already been set by a tool)
I would like to suggest you to read: S12 FAMILY DEVICES COP RECOGNITION CONSIDERATIONS_v2.0.pdf
The COP is usually not debuggable because the debugger loses connection during reset. Moreover, next issue of a reset recognition can be improper capacitance at reset pin which casues the COP is not recognized and the reset is considered as an POR reset so the start of the code is not at COP reset vector but at POR vector..
Capacitor calculation can be simply done by attached excel sheet (reset recognition).
Bets regards,
Ladislav
Great, Lama. You cut to point at the begining. Yes, it's the "write once" problem.
Now my watchdog is functioning well.
Thank you very much.
Bloom