HAL IWDG Use Cases

IWDG Refresh Correctly

@startuml

"User Application" -> "System" : HAL_Init()

"System" --> "User Application"

"User Application"->"Driver IWDG" : HAL_IWDG_Init()

"Driver IWDG" --> "User Application"

rnote over "User Application"

User can choose the value of the LSI frequency

depending on the value of : USE_IWDG_LSI_FREQ.

In case USE_IWDG_LSI_FREQ == 0, user must call

HAL_IWDG_SetLSIFrequency() to provide his own

LSI frequency.

endrnote

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n max_time, early_wakeup_time)

"Driver IWDG" --> "User Application"

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

rnote over "Driver IWDG"

<color #green>Refresh done before IWDCNT

<color #green>reaches 0x000

endrnote

rnote over "Driver IWDG"

<color #green>Operation ended successfully

endrnote

end

@enduml

Functions called:

IWDG Cannot Refresh

@startuml

"User Application" -> "System" : HAL_Init()

"System" --> "User Application"

"User Application"->"Driver IWDG" : HAL_IWDG_Init()

"Driver IWDG" --> "User Application"

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n max_time, early_wakeup_time)

"Driver IWDG" --> "User Application"

alt IWDG not expired

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

rnote over "Driver IWDG"

<color #green>Refresh done before IWDCNT

<color #green>reaches 0x000

endrnote

rnote over "Driver IWDG"

<color #green> Operation ended successfully

endrnote

end

else IWDG expired

"Driver IWDG" -> "Driver IWDG" : IWDG downcounter

"Driver IWDG" -[#red]> "System" : <color #red> IWDG reset </color>

rnote over "Driver IWDG"

<color #red>Following a malfunction due to software

<color #red>or hardware failures, the IWDG

<color #red>can not refresh

<color #red>When the IWDCNT reaches 0x000,

<color #red>a RESET signal is generated

endrnote

end

@enduml

Functions called:

LSI Frequency Modification

@startuml

"User Application" -> "System" : HAL_Init()

"System" --> "User Application"

rnote over "User Application"

USE_IWDG_LSI_FREQ == 0 (Dynamic LSI)

endrnote

"User Application"->"Driver IWDG" : HAL_IWDG_Init()

"Driver IWDG" --> "User Application"

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n max_time, early_wakeup_time)

"Driver IWDG" --> "User Application"

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

end

rnote over "User Application"

User chooses to provide his

own LSI frequency.

endrnote

"User Application"->"Driver IWDG" : HAL_IWDG_SetLSIFrequency()

"Driver IWDG" --> "User Application"

rnote over "User Application"

all parameters must be recalculated,

so a call to HAL_IWDG_Start() must

be done.

endrnote

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n max_time, early_wakeup_time)

"Driver IWDG" --> "User Application"

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

end

@enduml

Functions called:

Window Option is Activated

@startuml

"User Application" -> "System" : HAL_Init()

"System" --> "User Application"

"User Application"->"Driver IWDG" : HAL_IWDG_Init()

"Driver IWDG" --> "User Application"

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n max_time, early_wakeup_time)

"Driver IWDG" --> "User Application"

alt IWDG not expired

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

rnote over "Driver IWDG"

<color #green>Refresh done before IWDCNT

<color #green>reaches 0x000

endrnote

rnote over "Driver IWDG"

<color #green> Operation ended successfully

endrnote

end

else IWDG expired

"Driver IWDG" -> "Driver IWDG" : IWDG downcounter

"Driver IWDG" -[#red]> "System" : <color #red> IWDG reset </color>

rnote over "Driver IWDG"

<color #red>Following a malfunction due to software

<color #red>or hardware failures, the IWDG

<color #red>can not refresh

<color #red>When the IWDCNT reaches 0x000,

<color #red>a RESET signal is generated

endrnote

else Reload outside the window

"Driver IWDG" -[#red]> "System" : <color #red> IWDG reset </color>

rnote over "Driver IWDG"

<color #red>Reload operation is

<color #red>performed while the IWDCNT > WIN + 1

endrnote

end

@enduml

Functions called:

Early Wakeup Interrupt Option is Activated

@startuml

"User Application" -> "System" : HAL_Init()

"System" --> "User Application"

"User Application" -> "NVIC" : Enable NVIC

"NVIC" --> "User Application"

"User Application"->"Driver IWDG" : HAL_IWDG_Init()

"Driver IWDG" --> "User Application"

rnote over "User Application"

The user can choose

Option 1 or Option 2 or nothing.

endrnote

group Option 1 [USE REGISTER CALLBACKS]

"User Application" ->  "Driver IWDG" : HAL_IWDG_RegisterEarlyWakeupCallback\n(userIWDG_EarlyWakeUpCallback)

"Driver IWDG" --> "User Application" : return HAL_OK

end

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n max_time, early_wakeup_time)

"Driver IWDG" --> "User Application"

alt IWDG not expired

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

rnote over "Driver IWDG"

<color #green>Refresh done before IWDCNT

<color #green>reaches 0x000

endrnote

rnote over "Driver IWDG"

<color #green> Operation ended successfully

endrnote

end

else IWDG expired

rnote over "Driver IWDG"

<color #red>When the IWDCNT reaches EWIT - 1

endrnote

"IWDG_IRQHandler" <[#Blue]- "NVIC" : IWDG Early Wakeup interrupt

rnote over "Driver IWDG"

EWIF: Watchdog early interrupt flag = 1

endrnote

"IWDG_IRQHandler" -[#Blue]> "Driver IWDG" : HAL_IWDG_IRQHandler()

activate "Driver IWDG" #Blue

rnote over "Driver IWDG"

EWIF: Watchdog early interrupt flag = 0

endrnote

group Option 1 [USE REGISTER CALLBACKS]

"Driver IWDG" -[#Blue]> "User Application" :userIWDG_EarlyWakeUpCallback

"User Application" -[#Blue]-> "Driver IWDG"

end

group Option 2 [USE OVERRIDEN WEAK CALLBACKS]

"Driver IWDG" -[#Blue]> "User Application" : HAL_IWDG_EarlyWakeupCallback()

"User Application" -[#Blue]-> "Driver IWDG"

deactivate "Driver IWDG"

end

"Driver IWDG" -> "Driver IWDG" : IWDG downcounter

"Driver IWDG" -[#red]> "System" : <color #red> IWDG reset </color>

end

@enduml

Functions called:

Use Case for Max Time Adjustment

@startuml

"User Application" -> "System" : HAL_Init()

"System" --> "User Application"

"User Application"->"Driver IWDG" : HAL_IWDG_Init()

"Driver IWDG" --> "User Application"

rnote over "User Application"

USE_IWDG_LSI_FREQ  = LSI_VALUE: Lsi frequency is set to 32000

USE_IWDG_TIME_UNIT = 2: Time unit is in seconds.

User chooses 11s as max time.

endrnote

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n 11, early_wakeup_time)

"Driver IWDG" --> "User Application"

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

end

rnote over "User Application"

To know the max time assured by the IWDG driver

user can call HAL_IWDG_GetMaxTime() function.

endrnote

"User Application"->"Driver IWDG" : HAL_IWDG_GetMaxTime()

"Driver IWDG" -> "User Application" : 8s

rnote over "User Application"

To adjust the max time

user can call HAL_IWDG_GetStep_us() function

in order th khnow the step.

endrnote

"User Application"->"Driver IWDG" : HAL_IWDG_GetStep_us()

"Driver IWDG" -> "User Application" : 4000us

rnote over "User Application"

For a step = 4000us, the maximum assured time is

8s instead of 11s with an offset of 3s,

User can then propose 12s for more efficiency and 0 offset.

endrnote

"User Application" -> "Driver IWDG" : HAL_IWDG_Start(&hiwdg, min_time,\n 12, early_wakeup_time)

"Driver IWDG" --> "User Application"

group Loop [Can be repeated]

"Driver IWDG" ->x "Driver IWDG" : IWDG downcounter

"User Application" -> "Driver IWDG" : HAL_IWDG_Refresh()

end

@enduml

Functions called: