cancel
Showing results for 
Search instead for 
Did you mean: 

My IWDG init (stm32_IwdgSetup(..)) halts – why?

Terje Bøhler
Associate II

Hi.

I use the STM32F107 and shall implement the IWDG to supervise my SW.

But my IWDG init-code (stm32_IwdgSetup(..)):

1) stops/halts the MCU in the "IWDG->KR = 0xCCCC" statement below

2) MCU never proceeds/advances from the "IWDG->KR = 0xCCCC" statement

3) MCU restarts (caused by IWDG?)

4) Re-enter and halts/stops at the same "IWDG->KR = 0xCCCC" statement below, and so on …

__inline static void stm32_IwdgSetup (void) {	
// Bit 0 LSION: Internal low-speed oscillator enable
// Set and cleared by software.
// 0: Internal RC 40 kHz oscillator OFF 
 RCC->CSR |= (1<<0);               // LSI (internal low speed oscillator) enable, necessary for IWDG
// Bit 1 LSIRDY: Internal low-speed oscillator ready
// Set and cleared by hardware to indicate when the internal RC 40 kHz oscillator is stable.
// After the LSION bit is cleared, LSIRDY goes low after 3 internal RC 40 kHz oscillator clock
// cycles.
// 0: Internal RC 40 kHz oscillator not ready
// 1: Internal RC 40 kHz oscillator ready	
 while ((RCC->CSR & (1<<1)) == 0); // wait till LSI is ready
/*--------------------------------------------------------
 Define  IWDG PR and RLR settings
 *-------------------------------------------------------*/
IWDG->KR  = 0x5555; // enable write to PR, RLR
IWDG->PR  = 1; 
IWDG->RLR = 400;
IWDG->KR  = 0xAAAA; // Reload the watchdog
IWDG->KR  = 0xCCCC; // Start the watchdog (CODE WILL NOT PROCEED FROM HERE !?!?!)
} // end of stm32_IwdgSetup

What have I overseen?

I appreciate comments on this.

BR Terje Bøhler

0 REPLIES 0