You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix iwdg example and add code to disable iwdg in halt
When using the example to enable and use the iwdg i found that when i had my cpu enter halt the watchdog kept running and timed out even though i had enabled that the cpu should stop in halt mode.
I found looking at some legacy code that setting KR to 0xAA and not 0xCC fixed the problem.
Maybe the 0xAA is a copy paste error?
I have also added a function to disable watchdog in halt in the option bytes
I have played around with a STM8S Discovery board to check your observation and proposed changes. Here is my current status:
my code is pretty messy :-( However, I don't actively develop these device headers anymore, as all STM8 are now "not recommended for new designs". So much for the protocol... ;-)
I confirm that with the original example IWDG is running in HALT mode with AWU -> IWDG triggers a reset in HALT mode :-(
KR=0xCC starts IWDG via software (see RM0016 v14, section 14.3.1). Writing KR=0xAA only refreshes the counter, but does not start IWDG. I confirmed this experimentally
So far I haven't found a way to deactivate IWDG in HALT mode (with AWU) -> need to ask in STM user forum
IMHO your proposed function disable_iwdg_in_halt() should work for (at least most) STM8L/AL. However:
STM8S/AF apparently lack the respective option bit (see datasheet)
for STM8S/AF you also need to store the inverted NOPT, else the µC remains in a reset cycle
you should only modify the option bits you need, not write the whole byte. Else you risk overwriting the WWDG options
STM8S/AF doesn't support stopping IWDG in HALT mode, see here --> re-configure IWDG for 1s max. timeout, wake up via AWU periodically, service IWDG and re-enter HALT with AWU
I will check your proposal for STM8L/AL using a STM8L Discovery Board. Stay tuned...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix iwdg example and add code to disable iwdg in halt
When using the example to enable and use the iwdg i found that when i had my cpu enter halt the watchdog kept running and timed out even though i had enabled that the cpu should stop in halt mode.
I found looking at some legacy code that setting KR to 0xAA and not 0xCC fixed the problem.
Maybe the 0xAA is a copy paste error?
I have also added a function to disable watchdog in halt in the option bytes