Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
cubexHal.pdf
Скачиваний:
110
Добавлен:
10.02.2016
Размер:
16.16 Mб
Скачать

HAL IWDG Generic Driver

UM1725

35 HAL IWDG Generic Driver

35.1IWDG Firmware driver registers structures

35.1.1IWDG_InitTypeDef

Data Fields

uint32_t Prescaler

uint32_t Reload

Field Documentation

uint32_t IWDG_InitTypeDef::Prescaler

Select the prescaler of the IWDG. This parameter can be a value of IWDG_Prescaler

uint32_t IWDG_InitTypeDef::Reload

Specifies the IWDG down-counter reload value. This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF

35.1.2IWDG_HandleTypeDef

Data Fields

IWDG_TypeDef * Instance

IWDG_InitTypeDef Init

HAL_LockTypeDef Lock

__IO HAL_IWDG_StateTypeDef State

Field Documentation

IWDG_TypeDef* IWDG_HandleTypeDef::Instance

Register base address

IWDG_InitTypeDef IWDG_HandleTypeDef::Init

IWDG required parameters

HAL_LockTypeDef IWDG_HandleTypeDef::Lock

IWDG Locking object

__IO HAL_IWDG_StateTypeDef IWDG_HandleTypeDef::State

IWDG communication state

35.2IWDG Firmware driver API description

35.2.1IWDG Specific features

The IWDG can be started by either software or hardware (configurable through option byte).

452/900

DOCID025834 Rev 2

UM1725

HAL IWDG Generic Driver

The IWDG is clocked by its own dedicated Low-Speed clock (LSI) and thus stays active even if the main clock fails. Once the IWDG is started, the LSI is forced ON and cannot be disabled (LSI cannot be disabled too), and the counter starts counting down from the reset value of 0xFFF. When it reaches the end of count value (0x000) a system reset is generated.

The IWDG counter should be refreshed at regular intervals, otherwise the watchdog generates an MCU reset when the counter reaches 0.

The IWDG is implemented in the VDD voltage domain that is still functional in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). IWDGRST flag in RCC_CSR register can be used to inform when an IWDG reset occurs.

Min-max timeout value @32KHz (LSI): ~125us / ~32.7s The IWDG timeout may vary due to LSI frequency dispersion. STM32F4xx devices provide the capability to measure the LSI frequency (LSI clock connected internally to TIM5 CH4 input capture). The measured value can be used to have an IWDG timeout with an acceptable accuracy.

35.2.2How to use this driver

If Window option is disabled

Use IWDG using HAL_IWDG_Init() function to :

Enable write access to IWDG_PR, IWDG_RLR.

Configure the IWDG prescaler, counter reload value. This reload value will be loaded in the IWDG counter each time the counter is reloaded, then the IWDG will start counting down from this value.

Use IWDG using HAL_IWDG_Start() function to:

Reload IWDG counter with value defined in the IWDG_RLR register.

Start the IWDG, when the IWDG is used in software mode (no need to enable the LSI, it will be enabled by hardware).

Then the application program must refresh the IWDG counter at regular intervals during normal operation to prevent an MCU reset, using HAL_IWDG_Refresh() function.

if Window option is enabled:

Use IWDG using HAL_IWDG_Start() function to enable IWDG downcounter

Use IWDG using HAL_IWDG_Init() function to :

Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.

Configure the IWDG prescaler, reload value and window value.

Then the application program must refresh the IWDG counter at regular intervals during normal operation to prevent an MCU reset, using HAL_IWDG_Refresh() function.

IWDG HAL driver macros list

Below the list of most used macros in IWDG HAL driver.

__HAL_IWDG_START: Enable the IWDG peripheral

__HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in the reload register

__HAL_IWDG_GET_FLAG: Get the selected IWDG's flag status

35.2.3Initialization and de-initialization functions

This section provides functions allowing to:

DOCID025834 Rev 2

453/900

HAL IWDG Generic Driver

UM1725

Initialize the IWDG according to the specified parameters in the IWDG_InitTypeDef and create the associated handle

Initialize the IWDG MSP

DeInitialize IWDG MSP

This section contains the following APIs:

HAL_IWDG_Init()

HAL_IWDG_MspInit()

35.2.4IO operation functions

This section provides functions allowing to:

Start the IWDG.

Refresh the IWDG.

This section contains the following APIs:

HAL_IWDG_Start()

HAL_IWDG_Refresh()

35.2.5Peripheral State functions

This subsection permits to get in run-time the status of the peripheral and the data flow.

This section contains the following APIs:

HAL_IWDG_GetState()

35.2.6HAL_IWDG_Init

Function Name

HAL_StatusTypeDef HAL_IWDG_Init (IWDG_HandleTypeDef *

 

hiwdg)

Function Description

Initializes the IWDG according to the specified parameters in the

 

IWDG_InitTypeDef and creates the associated handle.

Parameters

 

hiwdg: pointer to a IWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified IWDG

 

 

module.

Return values

 

HAL status

35.2.7HAL_IWDG_MspInit

Function Name

void HAL_IWDG_MspInit (IWDG_HandleTypeDef * hiwdg)

Function Description

Initializes the IWDG MSP.

Parameters

 

hiwdg: pointer to a IWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified IWDG

 

 

module.

Return values

 

None

35.2.8HAL_IWDG_Start

Function Name

HAL_StatusTypeDef HAL_IWDG_Start (IWDG_HandleTypeDef

 

* hiwdg)

Function Description

Starts the IWDG.

454/900

DOCID025834 Rev 2

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]