tags: [entity] type: entity topic: stm32-lower note: 20 created: 2026-07-16
| # | Directory | Description |
|---|---|---|
| 27 | 27_iwdg_test_register |
IWDG test (register) |
| 28 | 28_iwdg_test_hal |
IWDG test (HAL) |
| — | (no project) | WWDG — code reference only |
| Claimed Path | Actual Path | Status |
|---|---|---|
stm32/27_iwdg_test_register/Hardware/IWDG/iwdg.c |
27_iwdg_test_register/Hardware/IWDG/iwdg.c |
✅ Correct |
stm32/27_iwdg_test_register/Hardware/IWDG/iwdg.h |
27_iwdg_test_register/Hardware/IWDG/iwdg.h |
✅ Correct |
stm32/27_iwdg_test_register/User/main.c |
27_iwdg_test_register/User/main.c |
✅ Correct |
stm32/28_iwdg_test_hal/Core/Src/main.c |
28_iwdg_test_hal/Core/Src/main.c |
✅ Correct |
| Claimed by Note | Actual Code | Match? |
|---|---|---|
IWDG->KR = 0xCCCC (enable) |
Line 14 | ✅ Match |
IWDG->KR = 0x5555 (enable write) |
Line 17 | ✅ Match |
IWDG->PR = 4 (PR=4 → prescaler 64) |
Line 20 | ✅ Match |
IWDG->RLR = 2499 |
Line 23 | ✅ Match |
IWDG->KR = 0xAAAA (refresh/feed) |
Line 32 | ✅ Match |
Note claims:
IWDG_Init(), then loop with Delay_ms(3000), flag toggle, IWDG_Refresh()Matches actual code.
Note states: PR=4 → divider=64, RLR=2499 → Tout = 2500 × 64 / 40000 ≈ 4s
The note's table correctly shows: | PR | Divider | Max Timeout (RLR=4095) | |---|---|---| | 100 (4) | 64 | 6.55s |
The actual timeout with RLR=2499:
CK_IWDG = LSI / (4 × 2^PR) = 40000 / (4 × 16) = 625 Hz
Tout = (RLR + 1) / CK_IWDG = 2500 / 625 = 4 seconds
⚠️ Note: The raw Joplin note shows a formula Tout = 2500 × 64 × 4 / 40000 = 16s with an erroneous extra ×4 factor. The correct timeout is 4 seconds at LSI=40KHz.
| Claimed by Note | Actual Code | Match? |
|---|---|---|
MX_IWDG_Init() generated by CubeMX |
Present | ✅ |
HAL_IWDG_Refresh(&hiwdg) |
Present | ✅ |
LSI must be enabled in RCC_OscInitStruct |
Present | ✅ |
Note describes WWDG configuration:
RCC->APB1ENR |= RCC_APB1ENR_WWDGEN;
WWDG->CFR |= WWDG_CFR_WDGTB_1 | WWDG_CFR_WDGTB_0; // ÷8
WWDG->CFR |= (0x50 << 0); // window value
WWDG->CR = 0x7F; // counter start
WWDG->CR |= WWDG_CR_WDGA; // enable
This is reference code only — no dedicated WWDG project directory exists.
Overall Accuracy: High
Issues Found:
Hardware/RTC/rtc.c (dependency for timing) — a detail not mentioned in the note