2015-07-29 07:47 AM
2015-07-29 08:22 AM
Some complementary info. I changed the prescaler from 32 to 256 and now the new code looks like below:
void wd_init(uint32_t timeout) { IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); // Enable write access to IWDG registers. IWDG_SetPrescaler(IWDG_Prescaler_256); // IWDG timer clock will be (LSI / 32). IWDG_SetReload(timeout * LSIFreq / 256); IWDG_ReloadCounter(); // Reload the IWDG counter (kick the dog for once!). IWDG_Enable(); // Enable IWDG (LSI will be enabled by hardware). } The code now works fine for up to 20 seconds timeout and not for more than that which is still the problem.2015-07-29 09:13 AM
The counter is only 12-bit, so you have to increase the prescaler so the math produces a number less than 4096.
For a 40 KHz source this equates to a maximum of around 26 seconds.To extend it further you're going to have to start with a slower clock. 32.768 KHz would give you 32 seconds.2015-07-29 09:42 AM
2015-07-29 09:49 AM
No, it is what it is, it's specified to be in the range of 30-60 KHz, nominally 40 KHz, my experience around 37 KHz, but haven't tested a statically meaningful number of them.
It's likely to be dependent to process, temperature and voltage.2015-07-29 10:57 AM
The IWDG clock input is dedicated to the LSI oscillator so you can't change the clock source.
2015-07-29 01:06 PM
Thanks! I thought that it should be like that.
2015-07-29 01:11 PM
Thanks clive1! Helpful as usual! :) I just wanted to know if there is any other way to define longer timeout than ~30 secs? I know that there can be watchdog with window. Would that be an alternative?
Thanks.