void wdt_enable(void) { RCC -> CSR = RCC -> CSR | 0x00000001; //Enable LSI Clock while((RCC -> CSR & 0x02)==0) { //add timeout code here } IWDG -> KR = 0x0000CCCC; //Enable IWDG IWDG -> KR = 0x00005555; //Enable register access IWDG -> PR = 0x010; //Set Prescaler /16 IWDG -> RLR = 0xFFF; //Set Reload Value for 2.048 seconds while(IWDG -> SR) //Check if flags are reset { //add timeout code here } IWDG -> KR = 0x0000AAAA; //Refresh the counter }