HAL IWDG Overview

Introducing IWDG

group IWDG_Introduction

  • This introduction is under development.

Module and files

The following diagram illustrates the IWDG module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the IWDG module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.



@startuml

!$use_ppp_core = 1

!$use_ppp_ll = 1

!$use_ppp_hal = 1

!$use_api_itf = 1

!$use_hal_itf = 1

!$use_ll_itf = 1

!$use_core_itf = 1

!$use_ppp_isr = 1

!$use_hal_service = 1

!$use_hal_rcc = 1

!$use_hal_dma = 0

!$use_ll_rcc = 0

!$ppp = "IWDG"

!$hal_api_itf = "HAL " + $ppp + " API"

!$appli_itf = "User Callback"

!$ppp_name = "HAL_"+$ppp

!$ppp_ISR = $ppp+" ISR"

!$ll_ppp = "LL_"+$ppp

!$hal_dma_itf = "HAL_DMA_StartDirectXfer()\nHAL_DMA_Abort_IT"

!$hal_rcc_itf = "\t\t\tHAL_RCC_GetPCLK1Freq()\n\t\t\tHAL_RCC_"+$ppp+"_EnableClock()"

!$hal_ppp_itf = "DMA CallBacks\nDMA Half transfer complete CallBack\nError CallBacks"

!$hal_generic_itf = "HAL_GetTick()"

!$ll_ppp_itf = "LL " + $ppp +" API"

!$ppp_xIRQ = $ppp+"x_IRQ"

<style>

componentDiagram {

arrow {

FontSize 8

}

interface {

FontSize 8

}

}

</style>

title $ppp Software Component Diagram

Package "Application Layer" #DarkMagenta {

component [Appli]

interface "$appli_itf" as APPLI_Interface

[Appli] -r- APPLI_Interface

}

package "HAL" #DarkOrange {

[$ppp_name]

!if ($use_hal_dma == 1)

interface "$hal_ppp_itf" as HAL_PPP_Interface

[$ppp_name] -d- HAL_PPP_Interface

!endif

interface "$hal_api_itf" as HAL_PPP_APPLI_Interface

[$ppp_name] -u- HAL_PPP_APPLI_Interface

!if ($use_hal_service == 1)

  [HAL_SERVICE]

  interface "$hal_generic_itf" as HAL_Service_Interface

  [HAL_SERVICE] -r- HAL_Service_Interface

  [$ppp_name] -l-( HAL_Service_Interface

!endif

!if ($use_hal_dma == 1)

  [HAL_DMA]

  interface "$hal_dma_itf" as HAL_DMA_Interface

  [HAL_DMA] -u- HAL_DMA_Interface

  [HAL_DMA] -u-( HAL_PPP_Interface

  [$ppp_name] --( HAL_DMA_Interface

!endif

!if ($use_hal_rcc == 1)

  [HAL_RCC]

  interface "$hal_rcc_itf" as HAL_RCC_Interface

  [HAL_RCC] -l- HAL_RCC_Interface

  [$ppp_name] -r-( HAL_RCC_Interface

!endif

}

[Appli] -d-( HAL_PPP_APPLI_Interface

[$ppp_name] -u-( APPLI_Interface

package "Low Layer" #Technology {

!if ($use_ppp_ll == 1)

  [$ll_ppp]

  interface "$ll_ppp_itf" as LL_PPP_Interface

  [$ll_ppp]  -u- LL_PPP_Interface

!endif

!if ($use_ppp_isr == 1)

interface "$ppp_ISR" as PPP_ISR

[$ppp_ISR] -U- PPP_ISR

[$ppp_ISR]

!endif

[CMSIS-Devices]

!if ($use_ll_rcc == 1)

  [LL_RCC]

  interface "LL RCC API" as LL_RCC_API

  [LL_RCC] -u- LL_RCC_API

  [HAL_RCC] -d-(LL_RCC_API

!endif

!if ($use_hal_dma == 1)

  [DMA ISR]

  interface "DMA ISR" as DMA_ISR

  [DMA ISR] -u- DMA_ISR

!endif

}

package "HW" #LightCyan {

[STM32_HW]

!if ($use_ppp_isr == 1)

interface "$ppp_xIRQ" as PPPx_IRQ

[STM32_HW] -u- PPPx_IRQ

!endif

!if ($use_hal_dma == 1)

interface "DMAx_IRQ_Ch" as DMA_IRQ_CH

[STM32_HW] -u- DMA_IRQ_CH

[DMA ISR] -d-( DMA_IRQ_CH

[HAL_DMA] --( DMA_ISR

!endif

}

!if ($use_ppp_ll == 1)

[$ppp_name] -d-( LL_PPP_Interface

[$ll_ppp] .r.> [CMSIS-Devices]: $ppp register def

[STM32_HW] <.u. [$ll_ppp] : $ppp registers R/W

!else

[$ppp_name] .d.> [CMSIS-Devices]: $ppp register def

[STM32_HW] <.l. [$ppp_name] : $ppp registers R/W

!endif

!if ($use_ppp_isr == 1)

[$ppp_ISR] -d-( PPPx_IRQ

[$ppp_name] -d-( PPP_ISR

!endif

!if ($use_ll_rcc == 1)

[STM32_HW] <.u. [LL_RCC] : RCC registers R/W

!endif

@enduml

Configuration table

The following table lists the configuration defines for the HAL IWDG module, specifying their locations, default values, and descriptions:

group IWDG_Configuration_Table

Configuration inside the IWDG driver:

Config defines

Where

Default value

Note

USE_HAL_IWDG_MODULE

hal_conf.h

1

Enable the HAL IWDG module.

USE_HAL_IWDG_REGISTER_CALLBACKS

hal_conf.h

0

Enable the register callbacks assert

USE_HAL_CHECK_PARAM

hal_conf.h

0

Enable checking of vital parameters at

runtime

USE_HAL_IWDG_HARDWARE_START

hal_conf.h

0

IWDG driver starts in HW mode

USE_HAL_IWDG_USER_DATA

hal_conf.h

0

Add an user data inside HAL IWDG handle

USE_HAL_IWDG_TIME_UNIT (*)

hal_conf.h

HAL_IWDG_TIME_UNIT_MS

Time unit to be used for IWDG driver

USE_HAL_IWDG_LSI_FREQ (**)

hal_conf.h

LSI_VALUE

LSI value to be applied to the IWDG driver

USE_ASSERT_DBG_PARAM

PreProcessor env

NA

Enable the params assert

USE_ASSERT_DBG_STATE

PreProcessor env

NA

Enable the state assert

(*) User can choose the value of the time Unit with the USE_HAL_IWDG_TIME_UNIT define:

  • HAL_IWDG_TIME_UNIT_US: IWDG driver time unit in microseconds.

  • HAL_IWDG_TIME_UNIT_MS: IWDG driver time unit in milliseconds.

  • HAL_IWDG_TIME_UNIT_S: IWDG driver time unit in seconds.

The default time unit is milliseconds if not set by the user.

(**) User can choose the value of the LSI frequency with the USE_HAL_IWDG_LSI_FREQ define:

  • LSI_VALUE_DYNAMIC: Dynamic LSI to be computed and set by the user.

  • LSI_VALUE: LSI value of 32kHz.

  • (LSI_VALUE / 128U): LSI value of 250Hz.

    The default LSI value is LSI_VALUE if not set by the user.

Allowed Maximum time ranges:

The selection of prescaler is done as follows: As long as the requested reset time value is lower than the max_time of a time range n, algorithm keeps the same prescaler n, once it exceeds the max_time of the range n, algorithm switch to the prescaler of the range n+1. The next table describes the possible Max time ranges for each prescaler and with both standard values of the LSI frequency:

Note:

  • For “Not supported” value in s, the user must switch to the ms or us unit. Same, for “Not supported” values in us, the user must switch to the ms or s unit.

  • In order to cover all the ranges, time unit static configuration has been introduced and can be expressed in us, ms or second.

LSI(Hz)

Prescaler

Step(us)

Max(us)

Max(ms)

Max(s)

32000

4

125

512000

512

Not supported

32000

8

250

1024000

1024

1.024

32000

16

500

2048000

2048

2.048

32000

32

1000

4096000

4096

4.096

32000

64

2000

8192000

8192

8.192

32000

128

4000

16384000

16384

16.384

32000

256

8000

32768000

32768

32.768

32000

512

16000

65536000

65536

65.536

32000

1024

32000

131072000

131072

131.072

250

4

16000

65536000

65536

65.536

250

8

32000

131072000

131072

131.072

250

16

64000

262144000

262144

262.144

250

32

128000

524288000

524288

524.288

250

64

256000

1048576000

1048576

1048.576

250

128

512000

2097152000

2097152

2097.152

250

256

1024000

4194304000

4194304

4194.304

250

512

2048000

Not supported

8388608

8388.608

250

1024

4096000

Not supported

16777216

16777.216