HAL Timer Functions ¶
Timer Initialization/Deinitialization function ¶
- group TIM_Exported_Functions_Group1
-
This group gathers functions for the initialization/deinitialization of a timer instance.
Functions
-
hal_status_t
HAL_TIM_Init
(
hal_tim_handle_t
*
htim
,
hal_tim_t
instance
)
¶
-
Initialization function. Initialize the TIM handle and associate an instance.
- Parameters :
-
-
htim – Pointer to the handler of the TIM instance.
-
instance – One of the value of the hal_tim_t enumeration.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_DeInit
(
hal_tim_handle_t
*
htim
)
¶
-
Reset function.
Stop all current operations and reset states.
Hence:
.
-
stop the counter
-
disable interrupts / DMA transfers
-
clear status flags
-
set channels’ states to RESET
-
set global state to RESET
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
-
-
hal_status_t
HAL_TIM_SetDMA
(
hal_tim_handle_t
*
htim
,
hal_tim_dma_index_t
dma_idx
,
hal_dma_handle_t
*
hdma
)
¶
-
Link a DMA handle to a DMA request.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
dma_idx – Index of the DMA request.
-
hdma – Pointer to a handle of the DMA instance.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Init
(
hal_tim_handle_t
*
htim
,
hal_tim_t
instance
)
¶
- group TIM_Exported_Functions_Group1
-
This group gathers functions for the initialization/deinitialization of a timer instance.
Functions
-
hal_status_t
HAL_TIM_Init
(
hal_tim_handle_t
*
htim
,
hal_tim_t
instance
)
-
Initialization function. Initialize the TIM handle and associate an instance.
- Parameters :
-
-
htim – Pointer to the handler of the TIM instance.
-
instance – One of the value of the hal_tim_t enumeration.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_DeInit
(
hal_tim_handle_t
*
htim
)
-
Reset function.
Stop all current operations and reset states.
Hence:
.
-
stop the counter
-
disable interrupts / DMA transfers
-
clear status flags
-
set channels’ states to RESET
-
set global state to RESET
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
-
-
hal_status_t
HAL_TIM_SetDMA
(
hal_tim_handle_t
*
htim
,
hal_tim_dma_index_t
dma_idx
,
hal_dma_handle_t
*
hdma
)
-
Link a DMA handle to a DMA request.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
dma_idx – Index of the DMA request.
-
hdma – Pointer to a handle of the DMA instance.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Init
(
hal_tim_handle_t
*
htim
,
hal_tim_t
instance
)
- group TIM_Exported_Functions_Group1
-
This group gathers functions for the initialization/deinitialization of a timer instance.
Functions
-
hal_status_t
HAL_TIM_Init
(
hal_tim_handle_t
*
htim
,
hal_tim_t
instance
)
-
Initialization function. Initialize the TIM handle and associate an instance.
- Parameters :
-
-
htim – Pointer to the handler of the TIM instance.
-
instance – One of the value of the hal_tim_t enumeration.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_DeInit
(
hal_tim_handle_t
*
htim
)
-
Reset function.
Stop all current operations and reset states.
Hence:
.
-
stop the counter
-
disable interrupts / DMA transfers
-
clear status flags
-
set channels’ states to RESET
-
set global state to RESET
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
-
-
hal_status_t
HAL_TIM_SetDMA
(
hal_tim_handle_t
*
htim
,
hal_tim_dma_index_t
dma_idx
,
hal_dma_handle_t
*
hdma
)
-
Link a DMA handle to a DMA request.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
dma_idx – Index of the DMA request.
-
hdma – Pointer to a handle of the DMA instance.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Init
(
hal_tim_handle_t
*
htim
,
hal_tim_t
instance
)
Timer Peripheral State, Error functions, Kernel Clock Frequency. ¶
- group TIM_Exported_Functions_Group2
-
This group gathers the functions for state, error and kernel clock management.
Functions
-
hal_tim_state_t
HAL_TIM_GetState
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the timer state.
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
- Return values :
-
hal_tim_state_t – HAL TIM state.
-
hal_tim_channel_state_t
HAL_TIM_GetChannelState
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Get the state of a channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel of interest
-
- Return values :
-
hal_tim_channel_state_t – TIM channel state
-
uint32_t
HAL_TIM_GetLastErrorCodes
(
const
hal_tim_handle_t
*
htim
)
¶
-
Retrieve the HAL TIM Last Errors.
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
- Return values :
-
uint32_t –
last error code.
Values can be:
-
uint32_t
HAL_TIM_GetClockFreq
(
const
hal_tim_handle_t
*
htim
)
¶
-
Return the peripheral clock frequency for TIM.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Frequency in Hz. 0 if the source clock of the TIM is not configured or not ready.
-
hal_tim_state_t
HAL_TIM_GetState
(
const
hal_tim_handle_t
*
htim
)
¶
- group TIM_Exported_Functions_Group2
-
This group gathers the functions for state, error and kernel clock management.
Functions
-
hal_tim_state_t
HAL_TIM_GetState
(
const
hal_tim_handle_t
*
htim
)
-
Get the timer state.
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
- Return values :
-
hal_tim_state_t – HAL TIM state.
-
hal_tim_channel_state_t
HAL_TIM_GetChannelState
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Get the state of a channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel of interest
-
- Return values :
-
hal_tim_channel_state_t – TIM channel state
-
uint32_t
HAL_TIM_GetLastErrorCodes
(
const
hal_tim_handle_t
*
htim
)
-
Retrieve the HAL TIM Last Errors.
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
- Return values :
-
uint32_t –
last error code.
Values can be:
-
uint32_t
HAL_TIM_GetClockFreq
(
const
hal_tim_handle_t
*
htim
)
-
Return the peripheral clock frequency for TIM.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Frequency in Hz. 0 if the source clock of the TIM is not configured or not ready.
-
hal_tim_state_t
HAL_TIM_GetState
(
const
hal_tim_handle_t
*
htim
)
- group TIM_Exported_Functions_Group2
-
This group gathers the functions for state, error and kernel clock management.
Functions
-
hal_tim_state_t
HAL_TIM_GetState
(
const
hal_tim_handle_t
*
htim
)
-
Get the timer state.
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
- Return values :
-
hal_tim_state_t – HAL TIM state.
-
hal_tim_channel_state_t
HAL_TIM_GetChannelState
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Get the state of a channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel of interest
-
- Return values :
-
hal_tim_channel_state_t – TIM channel state
-
uint32_t
HAL_TIM_GetLastErrorCodes
(
const
hal_tim_handle_t
*
htim
)
-
Retrieve the HAL TIM Last Errors.
- Parameters :
-
htim – Pointer to the handler of the TIM instance.
- Return values :
-
uint32_t –
last error code.
Values can be:
-
uint32_t
HAL_TIM_GetClockFreq
(
const
hal_tim_handle_t
*
htim
)
-
Return the peripheral clock frequency for TIM.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Frequency in Hz. 0 if the source clock of the TIM is not configured or not ready.
-
hal_tim_state_t
HAL_TIM_GetState
(
const
hal_tim_handle_t
*
htim
)
Timer Timebase configuration and control ¶
- group TIM_Exported_Functions_Group3
-
This group contains the functions used to configure and control the time base unit.
The configuration includes:
-
Clock source selection
-
internal
-
external mode 1
-
external mode 2
-
encoder mode
-
-
Autoreload setting
-
Prescaler setting
-
Repetition counter setting
-
Dithering management
Control functions start or stop the timer’s counter.
Three execution modes are proposed:
-
polling:
Neither update interrupt nor update DMA request are enabled.
It is up to the application to read/clear the update flag if needed. -
interrupt mode:
Update interrupt is enabled.
-
DMA mode (commutation disabled):
A DMA transfer is started in interrupt mode and Update DMA request is enabled.
At every update event, the DMA transfers one word from the memory to the autoreload register.
Note
-
When the slave mode controller is configured in trigger mode the timer’s counter isn’t started by the software. (the timer’s counter starts in response to an event on a selected trigger input)
-
When commutation is enabled
-
interrupt mode:
Commutation interrupt is enabled
-
DMA mode:
Commutation DMA request is enabled.
At every commutation event, the DMA transfer takes place as per DMA transfer configuration.
Note that in that case the start of the DMA transfer is under application’s responsibility.
-
-
When the slave node is enabled
-
interrupt mode:
Trigger interrupt is enabled.
-
Functions
-
hal_status_t
HAL_TIM_SetConfig
(
hal_tim_handle_t
*
htim
,
const
hal_tim_config_t
*
p_config
)
¶
-
Configure the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the time-base unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfig
(
const
hal_tim_handle_t
*
htim
,
hal_tim_config_t
*
p_config
)
¶
-
Get the configuration of the the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a time-base unit configuration structure to fill.
-
-
hal_status_t
HAL_TIM_SetPeriod
(
hal_tim_handle_t
*
htim
,
uint32_t
period
)
¶
-
Set the period of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
period – Period for the time base unit.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetPeriod
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the period of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Period of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetDitheredPeriod
(
hal_tim_handle_t
*
htim
,
uint32_t
period
,
hal_tim_dithering_pattern_t
period_dithering_pattern
)
¶
-
Set the period and dithering pattern of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
period – Period for the time base unit(integer part).
-
period_dithering_pattern – Dithering pattern for the period (period fractional part)
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_GetDitheredPeriod
(
const
hal_tim_handle_t
*
htim
,
uint32_t
*
p_period
,
hal_tim_dithering_pattern_t
*
p_period_dithering_pattern
)
¶
-
Get the period and its dithering pattern of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_period – Pointer for the period for the time base unit (period’s integer part).
-
p_period_dithering_pattern – Dithering pattern for the period (period’s fractional part)
-
-
hal_status_t
HAL_TIM_SetPrescaler
(
hal_tim_handle_t
*
htim
,
uint32_t
prescaler
)
¶
-
Set the prescaler of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
prescaler – Prescaler for the time base unit.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetPrescaler
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the prescaler value of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Prescaler value of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetCounterMode
(
hal_tim_handle_t
*
htim
,
hal_tim_counter_mode_t
counter_mode
)
¶
-
Set the counter mode of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
counter_mode – Counter mode.
-
- Return values :
-
HAL_OK –
-
hal_tim_counter_mode_t
HAL_TIM_GetCounterMode
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the counter mode of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_counter_mode_t – Counter mode of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetClockDivision
(
hal_tim_handle_t
*
htim
,
hal_tim_clk_division_t
clock_division
)
¶
-
Set the clock prescaler division factor (CKD).
Note
The prescaler set the division ratio between the timer kernel clock (tim_ker_ck) and the DTS sampling clock (DTS_ck).
Note
The DTS sampling clock is used by the dead-time generator (when supported), the break/break2 filters and internal digital filters.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
clock_division – The clock division.
-
- Return values :
-
HAL_OK –
-
hal_tim_clk_division_t
HAL_TIM_GetClockDivision
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the clock prescaler division factor (CKD).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_clk_division_t – Clock division for DTS sampling clock.
-
hal_status_t
HAL_TIM_SetRepetitionCounter
(
hal_tim_handle_t
*
htim
,
uint32_t
repetition_counter
)
¶
-
Set the repetition counter value of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
repetition_counter – Value of the repetition counter.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetRepetitionCounter
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the repetition counter value of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Repetition counter value of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetClockSource
(
hal_tim_handle_t
*
htim
,
const
hal_tim_clock_sel_t
*
p_clk_sel
)
¶
-
Set the clock source of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_clk_sel – Pointer to the clock selection. Clock selection is used to set the clock source of the timer’s time-base unit. If the clock source is HAL_TIM_CLK_EXTERNAL_MODE1 then the external trigger that is used as clock signal is also specified.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetClockSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_clock_sel_t
*
p_clk_sel
)
¶
-
Get the clock source of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_clk_sel – Pointer to the clock selection that gather 2 parameters:
-
clock_source for the clock source of the timer’s time-base unit.
-
trigger which is meaningful only in the case where the clock source is HAL_TIM_CLK_EXTERNAL_MODE1 . Then, it stores the value of the external trigger that is used as clock signal.
-
-
-
hal_status_t
HAL_TIM_SetCounter
(
hal_tim_handle_t
*
htim
,
uint32_t
counter_value
)
¶
-
Set Counter Register (TIMx_CNT) value at runtime.
Warning
When UIF bit remapping is enabled (see HAL_TIM_EnableUpdateFlagRemap ), bit 31 of the timer counter register is read-only. This might affect the counter range in case of 32-bit counter TIM instance.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
counter_value – Counter register new value.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetCounter
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get Counter Register (TIMx_CNT) value at runtime.
Note
When UIF bit remapping is enabled (see HAL_TIM_EnableUpdateFlagRemap ), bit 31 of the returned value contains a copy of the update interrupt flag (UIF).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – 16-bit or 32-bit value of the timer counter register (TIMx_CNT).
-
hal_status_t
HAL_TIM_EnableUpdateGeneration
(
hal_tim_handle_t
*
htim
)
¶
-
Enable update event generation.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableUpdateGeneration
(
hal_tim_handle_t
*
htim
)
¶
-
Disable update event generation.
Note
Once update event generation has been disabled, no update event occurs until HAL_TIM_EnableUpdateGeneration is called.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_update_generation_status_t
HAL_TIM_IsEnabledUpdateGeneration
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether update event generation is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_generation_status_t – Update Event Generation Status (Disabled/Enabled)
-
hal_status_t
HAL_TIM_SetUpdateSource
(
hal_tim_handle_t
*
htim
,
hal_tim_update_src_t
update_source
)
¶
-
Set update event source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
update_source – Source for the Update event.
-
- Return values :
-
HAL_OK –
-
hal_tim_update_src_t
HAL_TIM_GetUpdateSource
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get update event source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_src_t – Source of the update event.
-
hal_status_t
HAL_TIM_EnableUpdateFlagRemap
(
hal_tim_handle_t
*
htim
)
¶
-
Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableUpdateFlagRemap
(
hal_tim_handle_t
*
htim
)
¶
-
Disable the copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_update_flag_remap_status_t
HAL_TIM_IsEnabledUpdateFlagRemap
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether the copy of the update interrupt flag (UIF) into the timer counter register is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_flag_remap_status_t – Update interrupt flag copy status (Disabled/Enabled)
-
hal_status_t
HAL_TIM_EnableAutoReloadPreload
(
hal_tim_handle_t
*
htim
)
¶
-
Enable the auto-reload preload.
Note
When autoreload preload is enabled, autoreload (TIMx_ARR) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableAutoReloadPreload
(
hal_tim_handle_t
*
htim
)
¶
-
Disable the auto-reload preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_auto_reload_preload_status_t
HAL_TIM_IsEnabledAutoReloadPreload
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether autoreload preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_auto_reload_preload_status_t – Auto-reload preload status of TIM.
-
hal_status_t
HAL_TIM_EnableDithering
(
hal_tim_handle_t
*
htim
)
¶
-
Enable dithering for the timer.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableDithering
(
hal_tim_handle_t
*
htim
)
¶
-
Disable dithering for the timer.
Note
It is recommended to follow this sequence when disabling the dithering:
-
The Counter must be stopped HAL_TIM_Stop (_IT/_DMA) and Auto Reload preload disabled HAL_TIM_DisableAutoReloadPreload
-
The new Period without dithering must be set HAL_TIM_SetPeriod
-
The new Pulse values without dithering must be set HAL_TIM_OC_SetCompareUnitPulse
-
The Dithering must be disabled HAL_TIM_DisableDithering
-
Capture/compare interrupt flags must be cleared LL_TIM_ClearFlag_CC1 (for each channel)
-
The Counter can be re-enabled HAL_TIM_Start (_IT/_DMA) (eventually with Auto Reload preload).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
-
hal_tim_dithering_status_t
HAL_TIM_IsEnabledDithering
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether dithering is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_dithering_status_t – Dithering status of TIM.
-
hal_status_t
HAL_TIM_SetCaptureCompareDMAReqSource
(
hal_tim_handle_t
*
htim
,
hal_tim_cc_dmareq_src_t
cc_dmareq_source
)
¶
-
Set the source that triggers the capture/compare DMA request.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
cc_dmareq_source – Source for the Capture/Compare DMA request.
-
- Return values :
-
HAL_OK –
-
hal_tim_cc_dmareq_src_t
HAL_TIM_GetCaptureCompareDMAReqSource
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the source that triggers the capture/compare DMA request.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_cc_dmareq_src_t – The source that triggers the DMA request.
-
hal_status_t
HAL_TIM_Start
(
hal_tim_handle_t
*
htim
)
¶
-
Start the timer in polling mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Stop
(
hal_tim_handle_t
*
htim
)
¶
-
Stop the timer that was started in polling mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Start_IT
(
hal_tim_handle_t
*
htim
)
¶
-
Start the timer in interrupt mode (default TIM interrupts).
Note
The timer is started in interrupt mode with the default interrupts
-
update by default
-
commutation if capture/compare preloaded
-
trigger if slave mode enabled and commutation disabled or commutation software only
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
-
hal_status_t
HAL_TIM_Start_IT_Opt
(
hal_tim_handle_t
*
htim
,
uint32_t
interrupts
)
¶
-
Start the timer in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
interrupts – Selection of the TIM interrupts (subset of Optional interruptions
).
Can be any of the (meaningful) ored values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Stop_IT
(
hal_tim_handle_t
*
htim
)
¶
-
Stop the timer that was started in interrupt mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Start_DMA
(
hal_tim_handle_t
*
htim
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
¶
-
Start the timer in DMA mode (default DMA interrupts).
Note
One data will be transferred from the buffer to the autoreload register (TIMx_ARR) at each update event.
DMA transfer ends when all the data of the buffer have been transferred.
Note
HAL_TIM_SetDMA() must be called with the correct DMA index (see hal_tim_dma_index_t ) before calling this function.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Start_DMA_Opt
(
hal_tim_handle_t
*
htim
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
¶
-
Start the timer in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the buffer to the autoreload register (TIMx_ARR) at each update event.
DMA transfer ends when all the data of the buffer have been transferred.
Note
HAL_TIM_SetDMA() must be called with the correct DMA index (see hal_tim_dma_index_t ) before calling this function.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
interrupts – Selection of the DMA interrupts (subset of Optional interruptions
).
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Stop_DMA
(
hal_tim_handle_t
*
htim
)
¶
-
Stop the timer that was started in DMA mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
- group TIM_Exported_Functions_Group3
-
This group contains the functions used to configure and control the time base unit.
The configuration includes:
-
Clock source selection
-
internal
-
external mode 1
-
external mode 2
-
encoder mode
-
-
Autoreload setting
-
Prescaler setting
-
Repetition counter setting
-
Dithering management
Control functions start or stop the timer’s counter.
Three execution modes are proposed:
-
polling:
Neither update interrupt nor update DMA request are enabled.
It is up to the application to read/clear the update flag if needed. -
interrupt mode:
Update interrupt is enabled.
-
DMA mode (commutation disabled):
A DMA transfer is started in interrupt mode and Update DMA request is enabled.
At every update event, the DMA transfers one word from the memory to the autoreload register.
Note
-
When the slave mode controller is configured in trigger mode the timer’s counter isn’t started by the software. (the timer’s counter starts in response to an event on a selected trigger input)
-
When commutation is enabled
-
interrupt mode:
Commutation interrupt is enabled
-
DMA mode:
Commutation DMA request is enabled.
At every commutation event, the DMA transfer takes place as per DMA transfer configuration.
Note that in that case the start of the DMA transfer is under application’s responsibility.
-
-
When the slave node is enabled
-
interrupt mode:
Trigger interrupt is enabled.
-
Functions
-
hal_status_t
HAL_TIM_SetConfig
(
hal_tim_handle_t
*
htim
,
const
hal_tim_config_t
*
p_config
)
-
Configure the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the time-base unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfig
(
const
hal_tim_handle_t
*
htim
,
hal_tim_config_t
*
p_config
)
-
Get the configuration of the the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a time-base unit configuration structure to fill.
-
-
hal_status_t
HAL_TIM_SetPeriod
(
hal_tim_handle_t
*
htim
,
uint32_t
period
)
-
Set the period of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
period – Period for the time base unit.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetPeriod
(
const
hal_tim_handle_t
*
htim
)
-
Get the period of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Period of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetDitheredPeriod
(
hal_tim_handle_t
*
htim
,
uint32_t
period
,
hal_tim_dithering_pattern_t
period_dithering_pattern
)
-
Set the period and dithering pattern of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
period – Period for the time base unit(integer part).
-
period_dithering_pattern – Dithering pattern for the period (period fractional part)
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_GetDitheredPeriod
(
const
hal_tim_handle_t
*
htim
,
uint32_t
*
p_period
,
hal_tim_dithering_pattern_t
*
p_period_dithering_pattern
)
-
Get the period and its dithering pattern of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_period – Pointer for the period for the time base unit (period’s integer part).
-
p_period_dithering_pattern – Dithering pattern for the period (period’s fractional part)
-
-
hal_status_t
HAL_TIM_SetPrescaler
(
hal_tim_handle_t
*
htim
,
uint32_t
prescaler
)
-
Set the prescaler of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
prescaler – Prescaler for the time base unit.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetPrescaler
(
const
hal_tim_handle_t
*
htim
)
-
Get the prescaler value of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Prescaler value of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetCounterMode
(
hal_tim_handle_t
*
htim
,
hal_tim_counter_mode_t
counter_mode
)
-
Set the counter mode of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
counter_mode – Counter mode.
-
- Return values :
-
HAL_OK –
-
hal_tim_counter_mode_t
HAL_TIM_GetCounterMode
(
const
hal_tim_handle_t
*
htim
)
-
Get the counter mode of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_counter_mode_t – Counter mode of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetClockDivision
(
hal_tim_handle_t
*
htim
,
hal_tim_clk_division_t
clock_division
)
-
Set the clock prescaler division factor (CKD).
Note
The prescaler set the division ratio between the timer kernel clock (tim_ker_ck) and the DTS sampling clock (DTS_ck).
Note
The DTS sampling clock is used by the dead-time generator (when supported), the break/break2 filters and internal digital filters.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
clock_division – The clock division.
-
- Return values :
-
HAL_OK –
-
hal_tim_clk_division_t
HAL_TIM_GetClockDivision
(
const
hal_tim_handle_t
*
htim
)
-
Get the clock prescaler division factor (CKD).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_clk_division_t – Clock division for DTS sampling clock.
-
hal_status_t
HAL_TIM_SetRepetitionCounter
(
hal_tim_handle_t
*
htim
,
uint32_t
repetition_counter
)
-
Set the repetition counter value of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
repetition_counter – Value of the repetition counter.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetRepetitionCounter
(
const
hal_tim_handle_t
*
htim
)
-
Get the repetition counter value of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Repetition counter value of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetClockSource
(
hal_tim_handle_t
*
htim
,
const
hal_tim_clock_sel_t
*
p_clk_sel
)
-
Set the clock source of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_clk_sel – Pointer to the clock selection. Clock selection is used to set the clock source of the timer’s time-base unit. If the clock source is HAL_TIM_CLK_EXTERNAL_MODE1 then the external trigger that is used as clock signal is also specified.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetClockSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_clock_sel_t
*
p_clk_sel
)
-
Get the clock source of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_clk_sel – Pointer to the clock selection that gather 2 parameters:
-
clock_source for the clock source of the timer’s time-base unit.
-
trigger which is meaningful only in the case where the clock source is HAL_TIM_CLK_EXTERNAL_MODE1 . Then, it stores the value of the external trigger that is used as clock signal.
-
-
-
hal_status_t
HAL_TIM_SetCounter
(
hal_tim_handle_t
*
htim
,
uint32_t
counter_value
)
-
Set Counter Register (TIMx_CNT) value at runtime.
Warning
When UIF bit remapping is enabled (see HAL_TIM_EnableUpdateFlagRemap ), bit 31 of the timer counter register is read-only. This might affect the counter range in case of 32-bit counter TIM instance.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
counter_value – Counter register new value.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetCounter
(
const
hal_tim_handle_t
*
htim
)
-
Get Counter Register (TIMx_CNT) value at runtime.
Note
When UIF bit remapping is enabled (see HAL_TIM_EnableUpdateFlagRemap ), bit 31 of the returned value contains a copy of the update interrupt flag (UIF).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – 16-bit or 32-bit value of the timer counter register (TIMx_CNT).
-
hal_status_t
HAL_TIM_EnableUpdateGeneration
(
hal_tim_handle_t
*
htim
)
-
Enable update event generation.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableUpdateGeneration
(
hal_tim_handle_t
*
htim
)
-
Disable update event generation.
Note
Once update event generation has been disabled, no update event occurs until HAL_TIM_EnableUpdateGeneration is called.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_update_generation_status_t
HAL_TIM_IsEnabledUpdateGeneration
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether update event generation is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_generation_status_t – Update Event Generation Status (Disabled/Enabled)
-
hal_status_t
HAL_TIM_SetUpdateSource
(
hal_tim_handle_t
*
htim
,
hal_tim_update_src_t
update_source
)
-
Set update event source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
update_source – Source for the Update event.
-
- Return values :
-
HAL_OK –
-
hal_tim_update_src_t
HAL_TIM_GetUpdateSource
(
const
hal_tim_handle_t
*
htim
)
-
Get update event source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_src_t – Source of the update event.
-
hal_status_t
HAL_TIM_EnableUpdateFlagRemap
(
hal_tim_handle_t
*
htim
)
-
Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableUpdateFlagRemap
(
hal_tim_handle_t
*
htim
)
-
Disable the copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_update_flag_remap_status_t
HAL_TIM_IsEnabledUpdateFlagRemap
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the copy of the update interrupt flag (UIF) into the timer counter register is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_flag_remap_status_t – Update interrupt flag copy status (Disabled/Enabled)
-
hal_status_t
HAL_TIM_EnableAutoReloadPreload
(
hal_tim_handle_t
*
htim
)
-
Enable the auto-reload preload.
Note
When autoreload preload is enabled, autoreload (TIMx_ARR) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableAutoReloadPreload
(
hal_tim_handle_t
*
htim
)
-
Disable the auto-reload preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_auto_reload_preload_status_t
HAL_TIM_IsEnabledAutoReloadPreload
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether autoreload preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_auto_reload_preload_status_t – Auto-reload preload status of TIM.
-
hal_status_t
HAL_TIM_EnableDithering
(
hal_tim_handle_t
*
htim
)
-
Enable dithering for the timer.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableDithering
(
hal_tim_handle_t
*
htim
)
-
Disable dithering for the timer.
Note
It is recommended to follow this sequence when disabling the dithering:
-
The Counter must be stopped HAL_TIM_Stop (_IT/_DMA) and Auto Reload preload disabled HAL_TIM_DisableAutoReloadPreload
-
The new Period without dithering must be set HAL_TIM_SetPeriod
-
The new Pulse values without dithering must be set HAL_TIM_OC_SetCompareUnitPulse
-
The Dithering must be disabled HAL_TIM_DisableDithering
-
Capture/compare interrupt flags must be cleared LL_TIM_ClearFlag_CC1 (for each channel)
-
The Counter can be re-enabled HAL_TIM_Start (_IT/_DMA) (eventually with Auto Reload preload).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
-
hal_tim_dithering_status_t
HAL_TIM_IsEnabledDithering
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether dithering is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_dithering_status_t – Dithering status of TIM.
-
hal_status_t
HAL_TIM_SetCaptureCompareDMAReqSource
(
hal_tim_handle_t
*
htim
,
hal_tim_cc_dmareq_src_t
cc_dmareq_source
)
-
Set the source that triggers the capture/compare DMA request.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
cc_dmareq_source – Source for the Capture/Compare DMA request.
-
- Return values :
-
HAL_OK –
-
hal_tim_cc_dmareq_src_t
HAL_TIM_GetCaptureCompareDMAReqSource
(
const
hal_tim_handle_t
*
htim
)
-
Get the source that triggers the capture/compare DMA request.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_cc_dmareq_src_t – The source that triggers the DMA request.
-
hal_status_t
HAL_TIM_Start
(
hal_tim_handle_t
*
htim
)
-
Start the timer in polling mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Stop
(
hal_tim_handle_t
*
htim
)
-
Stop the timer that was started in polling mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Start_IT
(
hal_tim_handle_t
*
htim
)
-
Start the timer in interrupt mode (default TIM interrupts).
Note
The timer is started in interrupt mode with the default interrupts
-
update by default
-
commutation if capture/compare preloaded
-
trigger if slave mode enabled and commutation disabled or commutation software only
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
-
hal_status_t
HAL_TIM_Start_IT_Opt
(
hal_tim_handle_t
*
htim
,
uint32_t
interrupts
)
-
Start the timer in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
interrupts – Selection of the TIM interrupts (subset of Optional interruptions
).
Can be any of the (meaningful) ored values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Stop_IT
(
hal_tim_handle_t
*
htim
)
-
Stop the timer that was started in interrupt mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Start_DMA
(
hal_tim_handle_t
*
htim
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start the timer in DMA mode (default DMA interrupts).
Note
One data will be transferred from the buffer to the autoreload register (TIMx_ARR) at each update event.
DMA transfer ends when all the data of the buffer have been transferred.
Note
HAL_TIM_SetDMA() must be called with the correct DMA index (see hal_tim_dma_index_t ) before calling this function.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Start_DMA_Opt
(
hal_tim_handle_t
*
htim
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
-
Start the timer in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the buffer to the autoreload register (TIMx_ARR) at each update event.
DMA transfer ends when all the data of the buffer have been transferred.
Note
HAL_TIM_SetDMA() must be called with the correct DMA index (see hal_tim_dma_index_t ) before calling this function.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
interrupts – Selection of the DMA interrupts (subset of Optional interruptions
).
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Stop_DMA
(
hal_tim_handle_t
*
htim
)
-
Stop the timer that was started in DMA mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
- group TIM_Exported_Functions_Group3
-
This group contains the functions used to configure and control the time base unit.
The configuration includes:
-
Clock source selection
-
internal
-
external mode 1
-
external mode 2
-
encoder mode
-
-
Autoreload setting
-
Prescaler setting
-
Repetition counter setting
-
Dithering management
Control functions start or stop the timer’s counter.
Three execution modes are proposed:
-
polling:
Neither update interrupt nor update DMA request are enabled.
It is up to the application to read/clear the update flag if needed. -
interrupt mode:
Update interrupt is enabled.
-
DMA mode (commutation disabled):
A DMA transfer is started in interrupt mode and Update DMA request is enabled.
At every update event, the DMA transfers one word from the memory to the autoreload register.
Note
-
When the slave mode controller is configured in trigger mode the timer’s counter isn’t started by the software. (the timer’s counter starts in response to an event on a selected trigger input)
-
When commutation is enabled
-
interrupt mode:
Commutation interrupt is enabled
-
DMA mode:
Commutation DMA request is enabled.
At every commutation event, the DMA transfer takes place as per DMA transfer configuration.
Note that in that case the start of the DMA transfer is under application’s responsibility.
-
-
When the slave node is enabled
-
interrupt mode:
Trigger interrupt is enabled.
-
Functions
-
hal_status_t
HAL_TIM_SetConfig
(
hal_tim_handle_t
*
htim
,
const
hal_tim_config_t
*
p_config
)
-
Configure the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the time-base unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfig
(
const
hal_tim_handle_t
*
htim
,
hal_tim_config_t
*
p_config
)
-
Get the configuration of the the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a time-base unit configuration structure to fill.
-
-
hal_status_t
HAL_TIM_SetPeriod
(
hal_tim_handle_t
*
htim
,
uint32_t
period
)
-
Set the period of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
period – Period for the time base unit.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetPeriod
(
const
hal_tim_handle_t
*
htim
)
-
Get the period of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Period of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetDitheredPeriod
(
hal_tim_handle_t
*
htim
,
uint32_t
period
,
hal_tim_dithering_pattern_t
period_dithering_pattern
)
-
Set the period and dithering pattern of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
period – Period for the time base unit(integer part).
-
period_dithering_pattern – Dithering pattern for the period (period fractional part)
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_GetDitheredPeriod
(
const
hal_tim_handle_t
*
htim
,
uint32_t
*
p_period
,
hal_tim_dithering_pattern_t
*
p_period_dithering_pattern
)
-
Get the period and its dithering pattern of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_period – Pointer for the period for the time base unit (period’s integer part).
-
p_period_dithering_pattern – Dithering pattern for the period (period’s fractional part)
-
-
hal_status_t
HAL_TIM_SetPrescaler
(
hal_tim_handle_t
*
htim
,
uint32_t
prescaler
)
-
Set the prescaler of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
prescaler – Prescaler for the time base unit.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetPrescaler
(
const
hal_tim_handle_t
*
htim
)
-
Get the prescaler value of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Prescaler value of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetCounterMode
(
hal_tim_handle_t
*
htim
,
hal_tim_counter_mode_t
counter_mode
)
-
Set the counter mode of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
counter_mode – Counter mode.
-
- Return values :
-
HAL_OK –
-
hal_tim_counter_mode_t
HAL_TIM_GetCounterMode
(
const
hal_tim_handle_t
*
htim
)
-
Get the counter mode of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_counter_mode_t – Counter mode of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetClockDivision
(
hal_tim_handle_t
*
htim
,
hal_tim_clk_division_t
clock_division
)
-
Set the clock prescaler division factor (CKD).
Note
The prescaler set the division ratio between the timer kernel clock (tim_ker_ck) and the DTS sampling clock (DTS_ck).
Note
The DTS sampling clock is used by the dead-time generator (when supported), the break/break2 filters and internal digital filters.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
clock_division – The clock division.
-
- Return values :
-
HAL_OK –
-
hal_tim_clk_division_t
HAL_TIM_GetClockDivision
(
const
hal_tim_handle_t
*
htim
)
-
Get the clock prescaler division factor (CKD).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_clk_division_t – Clock division for DTS sampling clock.
-
hal_status_t
HAL_TIM_SetRepetitionCounter
(
hal_tim_handle_t
*
htim
,
uint32_t
repetition_counter
)
-
Set the repetition counter value of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
repetition_counter – Value of the repetition counter.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetRepetitionCounter
(
const
hal_tim_handle_t
*
htim
)
-
Get the repetition counter value of the timer’s time-base unit.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – Repetition counter value of the timer’s time-base unit.
-
hal_status_t
HAL_TIM_SetClockSource
(
hal_tim_handle_t
*
htim
,
const
hal_tim_clock_sel_t
*
p_clk_sel
)
-
Set the clock source of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_clk_sel – Pointer to the clock selection. Clock selection is used to set the clock source of the timer’s time-base unit. If the clock source is HAL_TIM_CLK_EXTERNAL_MODE1 then the external trigger that is used as clock signal is also specified.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetClockSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_clock_sel_t
*
p_clk_sel
)
-
Get the clock source of the timer’s time-base unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_clk_sel – Pointer to the clock selection that gather 2 parameters:
-
clock_source for the clock source of the timer’s time-base unit.
-
trigger which is meaningful only in the case where the clock source is HAL_TIM_CLK_EXTERNAL_MODE1 . Then, it stores the value of the external trigger that is used as clock signal.
-
-
-
hal_status_t
HAL_TIM_SetCounter
(
hal_tim_handle_t
*
htim
,
uint32_t
counter_value
)
-
Set Counter Register (TIMx_CNT) value at runtime.
Warning
When UIF bit remapping is enabled (see HAL_TIM_EnableUpdateFlagRemap ), bit 31 of the timer counter register is read-only. This might affect the counter range in case of 32-bit counter TIM instance.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
counter_value – Counter register new value.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_GetCounter
(
const
hal_tim_handle_t
*
htim
)
-
Get Counter Register (TIMx_CNT) value at runtime.
Note
When UIF bit remapping is enabled (see HAL_TIM_EnableUpdateFlagRemap ), bit 31 of the returned value contains a copy of the update interrupt flag (UIF).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – 16-bit or 32-bit value of the timer counter register (TIMx_CNT).
-
hal_status_t
HAL_TIM_EnableUpdateGeneration
(
hal_tim_handle_t
*
htim
)
-
Enable update event generation.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableUpdateGeneration
(
hal_tim_handle_t
*
htim
)
-
Disable update event generation.
Note
Once update event generation has been disabled, no update event occurs until HAL_TIM_EnableUpdateGeneration is called.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_update_generation_status_t
HAL_TIM_IsEnabledUpdateGeneration
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether update event generation is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_generation_status_t – Update Event Generation Status (Disabled/Enabled)
-
hal_status_t
HAL_TIM_SetUpdateSource
(
hal_tim_handle_t
*
htim
,
hal_tim_update_src_t
update_source
)
-
Set update event source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
update_source – Source for the Update event.
-
- Return values :
-
HAL_OK –
-
hal_tim_update_src_t
HAL_TIM_GetUpdateSource
(
const
hal_tim_handle_t
*
htim
)
-
Get update event source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_src_t – Source of the update event.
-
hal_status_t
HAL_TIM_EnableUpdateFlagRemap
(
hal_tim_handle_t
*
htim
)
-
Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableUpdateFlagRemap
(
hal_tim_handle_t
*
htim
)
-
Disable the copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_update_flag_remap_status_t
HAL_TIM_IsEnabledUpdateFlagRemap
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the copy of the update interrupt flag (UIF) into the timer counter register is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_update_flag_remap_status_t – Update interrupt flag copy status (Disabled/Enabled)
-
hal_status_t
HAL_TIM_EnableAutoReloadPreload
(
hal_tim_handle_t
*
htim
)
-
Enable the auto-reload preload.
Note
When autoreload preload is enabled, autoreload (TIMx_ARR) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableAutoReloadPreload
(
hal_tim_handle_t
*
htim
)
-
Disable the auto-reload preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_auto_reload_preload_status_t
HAL_TIM_IsEnabledAutoReloadPreload
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether autoreload preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_auto_reload_preload_status_t – Auto-reload preload status of TIM.
-
hal_status_t
HAL_TIM_EnableDithering
(
hal_tim_handle_t
*
htim
)
-
Enable dithering for the timer.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableDithering
(
hal_tim_handle_t
*
htim
)
-
Disable dithering for the timer.
Note
It is recommended to follow this sequence when disabling the dithering:
-
The Counter must be stopped HAL_TIM_Stop (_IT/_DMA) and Auto Reload preload disabled HAL_TIM_DisableAutoReloadPreload
-
The new Period without dithering must be set HAL_TIM_SetPeriod
-
The new Pulse values without dithering must be set HAL_TIM_OC_SetCompareUnitPulse
-
The Dithering must be disabled HAL_TIM_DisableDithering
-
Capture/compare interrupt flags must be cleared LL_TIM_ClearFlag_CC1 (for each channel)
-
The Counter can be re-enabled HAL_TIM_Start (_IT/_DMA) (eventually with Auto Reload preload).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
-
hal_tim_dithering_status_t
HAL_TIM_IsEnabledDithering
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether dithering is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_dithering_status_t – Dithering status of TIM.
-
hal_status_t
HAL_TIM_SetCaptureCompareDMAReqSource
(
hal_tim_handle_t
*
htim
,
hal_tim_cc_dmareq_src_t
cc_dmareq_source
)
-
Set the source that triggers the capture/compare DMA request.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
cc_dmareq_source – Source for the Capture/Compare DMA request.
-
- Return values :
-
HAL_OK –
-
hal_tim_cc_dmareq_src_t
HAL_TIM_GetCaptureCompareDMAReqSource
(
const
hal_tim_handle_t
*
htim
)
-
Get the source that triggers the capture/compare DMA request.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_cc_dmareq_src_t – The source that triggers the DMA request.
-
hal_status_t
HAL_TIM_Start
(
hal_tim_handle_t
*
htim
)
-
Start the timer in polling mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Stop
(
hal_tim_handle_t
*
htim
)
-
Stop the timer that was started in polling mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Start_IT
(
hal_tim_handle_t
*
htim
)
-
Start the timer in interrupt mode (default TIM interrupts).
Note
The timer is started in interrupt mode with the default interrupts
-
update by default
-
commutation if capture/compare preloaded
-
trigger if slave mode enabled and commutation disabled or commutation software only
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
-
hal_status_t
HAL_TIM_Start_IT_Opt
(
hal_tim_handle_t
*
htim
,
uint32_t
interrupts
)
-
Start the timer in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
interrupts – Selection of the TIM interrupts (subset of Optional interruptions
).
Can be any of the (meaningful) ored values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Stop_IT
(
hal_tim_handle_t
*
htim
)
-
Stop the timer that was started in interrupt mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_Start_DMA
(
hal_tim_handle_t
*
htim
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start the timer in DMA mode (default DMA interrupts).
Note
One data will be transferred from the buffer to the autoreload register (TIMx_ARR) at each update event.
DMA transfer ends when all the data of the buffer have been transferred.
Note
HAL_TIM_SetDMA() must be called with the correct DMA index (see hal_tim_dma_index_t ) before calling this function.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Start_DMA_Opt
(
hal_tim_handle_t
*
htim
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
-
Start the timer in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the buffer to the autoreload register (TIMx_ARR) at each update event.
DMA transfer ends when all the data of the buffer have been transferred.
Note
HAL_TIM_SetDMA() must be called with the correct DMA index (see hal_tim_dma_index_t ) before calling this function.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
interrupts – Selection of the DMA interrupts (subset of Optional interruptions
).
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_Stop_DMA
(
hal_tim_handle_t
*
htim
)
-
Stop the timer that was started in DMA mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
Timer Output Channel functions ¶
- group TIM_Exported_Functions_Group4
-
This group contains the functions used to configure and control the output stage of the timer’s capture/compare channels.
The output stage of a timer can be used to
-
control an output waveform
-
generate complementary PWM signals with deadtime insertion
-
indicate when a period of time has elapsed
The configuration of an output channel includes:
-
selection of the output mode (e.g. output compare, PWM, …)
-
selection of the channel polarity
-
setting of the compare value
Control functions enable or disable the timer’s output channel.
Three execution modes are proposed:
-
polling
Neither compare match interrupt nor compare match DMA request are enabled.
It is up to the application to read/clear the compare match flag if needed. -
interrupt mode
Compare match interrupt is enabled for the concerned channel.
-
DMA
A DMA transfer is started in interrupt mode and compare match DMA request is enabled.
At every compare match event, the DMA transfers one word from the memory to the capture/compare register.
Functions
-
hal_status_t
HAL_TIM_OC_SetConfigCompareUnit
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
const
hal_tim_oc_compare_unit_config_t
*
p_config
)
¶
-
Configure an output compare unit.
Note
If dithering is activated, the value of pulse is split in two parts: bits[31:4] holds the integer part and bits[3:0] the fractional part.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit to configure.
-
p_config – Pointer to an output compare unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetConfigCompareUnit
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
hal_tim_oc_compare_unit_config_t
*
p_config
)
¶
-
Get the configuration of an output compare unit.
Note
If dithering is activated, pay attention to the returned value interpretation.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
p_config – Pointer to an output compare unit configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetCompareUnitPulse
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
pulse
)
¶
-
Set the pulse of an output compare unit.
Note
The pulse value can also include the fractional part for the dithering mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
pulse – Compare match value.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_OC_GetCompareUnitPulse
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
)
¶
-
Get the pulse of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
- Return values :
-
uint32_t – Compare match value
-
hal_status_t
HAL_TIM_OC_SetCompareUnitDitheredPulse
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
pulse
,
hal_tim_dithering_pattern_t
pulse_dithering_pattern
)
¶
-
Set the pulse and dithering pattern of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit to configure.
-
pulse – Compare match value (integer part).
-
pulse_dithering_pattern – Dithering pattern for the pulse (fractional part).
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_OC_GetCompareUnitDitheredPulse
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
*
p_pulse
,
hal_tim_dithering_pattern_t
*
p_pulse_dithering_pattern
)
¶
-
Get the pulse and dithering pattern of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
p_pulse – Pointer to compare match value (integer part).
-
p_pulse_dithering_pattern – Pointer to dithering pattern for the pulse (fractional part)
-
-
hal_status_t
HAL_TIM_OC_SetConfigChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
hal_tim_oc_channel_config_t
*
p_config
)
¶
-
Configure an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel to configure.
-
p_config – Pointer to an output channel configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetConfigChannel
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_oc_channel_config_t
*
p_config
)
¶
-
Get the configuration of an Output Channel.
Note
There is no check that the channel direction is indeed output.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel.
-
p_config – Pointer to an output channel configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetPulseGenerator
(
hal_tim_handle_t
*
htim
,
const
hal_tim_pulse_generator_config_t
*
p_config
)
¶
-
Program the pulse width and prescaler when the output channel operates in pulse on compare mode.
Note
Pulse on compare mode is only available on channel 3 and channel 4.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a pulse generation configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetPulseGenerator
(
const
hal_tim_handle_t
*
htim
,
hal_tim_pulse_generator_config_t
*
p_config
)
¶
-
Get the pulse width and prescaler of an output channel operating in pulse on compare mode.
Note
Pulse on compare mode is only available on channel 3 and channel 4.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a pulse generation configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetGroupChannel
(
hal_tim_handle_t
*
htim
,
uint32_t
group
)
¶
-
Select on which reference signal the OC5REF (i.e. output compare of channel 5) is combined to.
Note
When OC5REF is grouped with OCxREF, resulting tim_ocxrefc is made of an AND logical combination of two reference PWMs.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
group – This parameter can be a combination of the following values:
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_OC_GetGroupChannel
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the group configuration of OC5REF signal of timer. That is, it returns a bitfield that informs if any of the output channels 1, 2 and 3 is combined with output channel 5.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – OC5REF signal which is a combination of the following values:
-
hal_status_t
HAL_TIM_OC_EnableChannelComparePreload
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Enable compare register (TIMx_CCRy) preload of an output channel.
Note
When output compare preload is enabled, compare (TIMx_CCRy) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_DisableChannelComparePreload
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Disable register (TIMx_CCRy) compare preload of an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_compare_preload_status_t
HAL_TIM_OC_IsEnabledChannelComparePreload
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Tell whether output compare preload is enabled or not for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
hal_tim_oc_compare_preload_status_t – Compare preload status.
-
hal_status_t
HAL_TIM_OC_EnableChannelFastMode
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Enable fast mode for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_DisableChannelFastMode
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Disable fast mode for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_channel_fast_mode_status_t
HAL_TIM_OC_IsEnabledChannelFastMode
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Tell whether fast mode is enabled or not for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
hal_tim_oc_channel_fast_mode_status_t – Fast Mode status.
-
hal_status_t
HAL_TIM_OC_StartChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Start a timer’s output channel in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StopChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Stop a timer’s output channel that was started in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StartChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Start a timer’s output channel in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StopChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Stop a timer’s output channel that was started in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StartChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
¶
-
Start a timer’s Output Channel in DMA mode (default DMA interrupts).
Note
One data will be transferred from the buffer to the compare register (TIMx_CCRy) at each compare match.
DMA transfer ends when all the data of the buffer have been transferred.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in byte).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_OC_StartChannel_DMA_Opt
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
¶
-
Start a timer’s Output Channel in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the buffer to the compare register (TIMx_CCRy) at each compare match.
DMA transfer ends when all the data of the buffer have been transferred.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in byte).
-
interrupts –
Selection of the DMA interrupts.
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_OC_StopChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Stop a timer’s output channel that was started in DMA mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output Channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_compare_unit_t
hal_tim_oc_channel_to_compare_unit
(
hal_tim_channel_t
channel
)
¶
-
Helper function to get a compare unit from an output channel.
- Parameters :
-
channel –
Output channel.
Must be one of the following values:
- Return values :
-
hal_tim_oc_compare_unit_t – Compare unit corresponding to the output channel.
-
- group TIM_Exported_Functions_Group4
-
This group contains the functions used to configure and control the output stage of the timer’s capture/compare channels.
The output stage of a timer can be used to
-
control an output waveform
-
generate complementary PWM signals with deadtime insertion
-
indicate when a period of time has elapsed
The configuration of an output channel includes:
-
selection of the output mode (e.g. output compare, PWM, …)
-
selection of the channel polarity
-
setting of the compare value
Control functions enable or disable the timer’s output channel.
Three execution modes are proposed:
-
polling
Neither compare match interrupt nor compare match DMA request are enabled.
It is up to the application to read/clear the compare match flag if needed. -
interrupt mode
Compare match interrupt is enabled for the concerned channel.
-
DMA
A DMA transfer is started in interrupt mode and compare match DMA request is enabled.
At every compare match event, the DMA transfers one word from the memory to the capture/compare register.
Functions
-
hal_status_t
HAL_TIM_OC_SetConfigCompareUnit
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
const
hal_tim_oc_compare_unit_config_t
*
p_config
)
-
Configure an output compare unit.
Note
If dithering is activated, the value of pulse is split in two parts: bits[31:4] holds the integer part and bits[3:0] the fractional part.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit to configure.
-
p_config – Pointer to an output compare unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetConfigCompareUnit
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
hal_tim_oc_compare_unit_config_t
*
p_config
)
-
Get the configuration of an output compare unit.
Note
If dithering is activated, pay attention to the returned value interpretation.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
p_config – Pointer to an output compare unit configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetCompareUnitPulse
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
pulse
)
-
Set the pulse of an output compare unit.
Note
The pulse value can also include the fractional part for the dithering mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
pulse – Compare match value.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_OC_GetCompareUnitPulse
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
)
-
Get the pulse of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
- Return values :
-
uint32_t – Compare match value
-
hal_status_t
HAL_TIM_OC_SetCompareUnitDitheredPulse
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
pulse
,
hal_tim_dithering_pattern_t
pulse_dithering_pattern
)
-
Set the pulse and dithering pattern of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit to configure.
-
pulse – Compare match value (integer part).
-
pulse_dithering_pattern – Dithering pattern for the pulse (fractional part).
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_OC_GetCompareUnitDitheredPulse
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
*
p_pulse
,
hal_tim_dithering_pattern_t
*
p_pulse_dithering_pattern
)
-
Get the pulse and dithering pattern of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
p_pulse – Pointer to compare match value (integer part).
-
p_pulse_dithering_pattern – Pointer to dithering pattern for the pulse (fractional part)
-
-
hal_status_t
HAL_TIM_OC_SetConfigChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
hal_tim_oc_channel_config_t
*
p_config
)
-
Configure an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel to configure.
-
p_config – Pointer to an output channel configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetConfigChannel
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_oc_channel_config_t
*
p_config
)
-
Get the configuration of an Output Channel.
Note
There is no check that the channel direction is indeed output.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel.
-
p_config – Pointer to an output channel configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetPulseGenerator
(
hal_tim_handle_t
*
htim
,
const
hal_tim_pulse_generator_config_t
*
p_config
)
-
Program the pulse width and prescaler when the output channel operates in pulse on compare mode.
Note
Pulse on compare mode is only available on channel 3 and channel 4.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a pulse generation configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetPulseGenerator
(
const
hal_tim_handle_t
*
htim
,
hal_tim_pulse_generator_config_t
*
p_config
)
-
Get the pulse width and prescaler of an output channel operating in pulse on compare mode.
Note
Pulse on compare mode is only available on channel 3 and channel 4.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a pulse generation configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetGroupChannel
(
hal_tim_handle_t
*
htim
,
uint32_t
group
)
-
Select on which reference signal the OC5REF (i.e. output compare of channel 5) is combined to.
Note
When OC5REF is grouped with OCxREF, resulting tim_ocxrefc is made of an AND logical combination of two reference PWMs.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
group – This parameter can be a combination of the following values:
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_OC_GetGroupChannel
(
const
hal_tim_handle_t
*
htim
)
-
Get the group configuration of OC5REF signal of timer. That is, it returns a bitfield that informs if any of the output channels 1, 2 and 3 is combined with output channel 5.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – OC5REF signal which is a combination of the following values:
-
hal_status_t
HAL_TIM_OC_EnableChannelComparePreload
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Enable compare register (TIMx_CCRy) preload of an output channel.
Note
When output compare preload is enabled, compare (TIMx_CCRy) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_DisableChannelComparePreload
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Disable register (TIMx_CCRy) compare preload of an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_compare_preload_status_t
HAL_TIM_OC_IsEnabledChannelComparePreload
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Tell whether output compare preload is enabled or not for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
hal_tim_oc_compare_preload_status_t – Compare preload status.
-
hal_status_t
HAL_TIM_OC_EnableChannelFastMode
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Enable fast mode for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_DisableChannelFastMode
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Disable fast mode for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_channel_fast_mode_status_t
HAL_TIM_OC_IsEnabledChannelFastMode
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Tell whether fast mode is enabled or not for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
hal_tim_oc_channel_fast_mode_status_t – Fast Mode status.
-
hal_status_t
HAL_TIM_OC_StartChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s output channel in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StopChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s output channel that was started in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StartChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s output channel in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StopChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s output channel that was started in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StartChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start a timer’s Output Channel in DMA mode (default DMA interrupts).
Note
One data will be transferred from the buffer to the compare register (TIMx_CCRy) at each compare match.
DMA transfer ends when all the data of the buffer have been transferred.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in byte).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_OC_StartChannel_DMA_Opt
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
-
Start a timer’s Output Channel in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the buffer to the compare register (TIMx_CCRy) at each compare match.
DMA transfer ends when all the data of the buffer have been transferred.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in byte).
-
interrupts –
Selection of the DMA interrupts.
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_OC_StopChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s output channel that was started in DMA mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output Channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_compare_unit_t
hal_tim_oc_channel_to_compare_unit
(
hal_tim_channel_t
channel
)
-
Helper function to get a compare unit from an output channel.
- Parameters :
-
channel –
Output channel.
Must be one of the following values:
- Return values :
-
hal_tim_oc_compare_unit_t – Compare unit corresponding to the output channel.
-
- group TIM_Exported_Functions_Group4
-
This group contains the functions used to configure and control the output stage of the timer’s capture/compare channels.
The output stage of a timer can be used to
-
control an output waveform
-
generate complementary PWM signals with deadtime insertion
-
indicate when a period of time has elapsed
The configuration of an output channel includes:
-
selection of the output mode (e.g. output compare, PWM, …)
-
selection of the channel polarity
-
setting of the compare value
Control functions enable or disable the timer’s output channel.
Three execution modes are proposed:
-
polling
Neither compare match interrupt nor compare match DMA request are enabled.
It is up to the application to read/clear the compare match flag if needed. -
interrupt mode
Compare match interrupt is enabled for the concerned channel.
-
DMA
A DMA transfer is started in interrupt mode and compare match DMA request is enabled.
At every compare match event, the DMA transfers one word from the memory to the capture/compare register.
Functions
-
hal_status_t
HAL_TIM_OC_SetConfigCompareUnit
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
const
hal_tim_oc_compare_unit_config_t
*
p_config
)
-
Configure an output compare unit.
Note
If dithering is activated, the value of pulse is split in two parts: bits[31:4] holds the integer part and bits[3:0] the fractional part.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit to configure.
-
p_config – Pointer to an output compare unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetConfigCompareUnit
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
hal_tim_oc_compare_unit_config_t
*
p_config
)
-
Get the configuration of an output compare unit.
Note
If dithering is activated, pay attention to the returned value interpretation.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
p_config – Pointer to an output compare unit configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetCompareUnitPulse
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
pulse
)
-
Set the pulse of an output compare unit.
Note
The pulse value can also include the fractional part for the dithering mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
pulse – Compare match value.
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_OC_GetCompareUnitPulse
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
)
-
Get the pulse of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
- Return values :
-
uint32_t – Compare match value
-
hal_status_t
HAL_TIM_OC_SetCompareUnitDitheredPulse
(
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
pulse
,
hal_tim_dithering_pattern_t
pulse_dithering_pattern
)
-
Set the pulse and dithering pattern of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit to configure.
-
pulse – Compare match value (integer part).
-
pulse_dithering_pattern – Dithering pattern for the pulse (fractional part).
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_OC_GetCompareUnitDitheredPulse
(
const
hal_tim_handle_t
*
htim
,
hal_tim_oc_compare_unit_t
compare_unit
,
uint32_t
*
p_pulse
,
hal_tim_dithering_pattern_t
*
p_pulse_dithering_pattern
)
-
Get the pulse and dithering pattern of an output compare unit.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
compare_unit – Output compare unit.
-
p_pulse – Pointer to compare match value (integer part).
-
p_pulse_dithering_pattern – Pointer to dithering pattern for the pulse (fractional part)
-
-
hal_status_t
HAL_TIM_OC_SetConfigChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
hal_tim_oc_channel_config_t
*
p_config
)
-
Configure an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel to configure.
-
p_config – Pointer to an output channel configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetConfigChannel
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_oc_channel_config_t
*
p_config
)
-
Get the configuration of an Output Channel.
Note
There is no check that the channel direction is indeed output.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel.
-
p_config – Pointer to an output channel configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetPulseGenerator
(
hal_tim_handle_t
*
htim
,
const
hal_tim_pulse_generator_config_t
*
p_config
)
-
Program the pulse width and prescaler when the output channel operates in pulse on compare mode.
Note
Pulse on compare mode is only available on channel 3 and channel 4.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a pulse generation configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_OC_GetPulseGenerator
(
const
hal_tim_handle_t
*
htim
,
hal_tim_pulse_generator_config_t
*
p_config
)
-
Get the pulse width and prescaler of an output channel operating in pulse on compare mode.
Note
Pulse on compare mode is only available on channel 3 and channel 4.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a pulse generation configuration structure.
-
-
hal_status_t
HAL_TIM_OC_SetGroupChannel
(
hal_tim_handle_t
*
htim
,
uint32_t
group
)
-
Select on which reference signal the OC5REF (i.e. output compare of channel 5) is combined to.
Note
When OC5REF is grouped with OCxREF, resulting tim_ocxrefc is made of an AND logical combination of two reference PWMs.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
group – This parameter can be a combination of the following values:
-
- Return values :
-
HAL_OK –
-
uint32_t
HAL_TIM_OC_GetGroupChannel
(
const
hal_tim_handle_t
*
htim
)
-
Get the group configuration of OC5REF signal of timer. That is, it returns a bitfield that informs if any of the output channels 1, 2 and 3 is combined with output channel 5.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
uint32_t – OC5REF signal which is a combination of the following values:
-
hal_status_t
HAL_TIM_OC_EnableChannelComparePreload
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Enable compare register (TIMx_CCRy) preload of an output channel.
Note
When output compare preload is enabled, compare (TIMx_CCRy) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_DisableChannelComparePreload
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Disable register (TIMx_CCRy) compare preload of an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_compare_preload_status_t
HAL_TIM_OC_IsEnabledChannelComparePreload
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Tell whether output compare preload is enabled or not for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
hal_tim_oc_compare_preload_status_t – Compare preload status.
-
hal_status_t
HAL_TIM_OC_EnableChannelFastMode
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Enable fast mode for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_DisableChannelFastMode
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Disable fast mode for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_channel_fast_mode_status_t
HAL_TIM_OC_IsEnabledChannelFastMode
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Tell whether fast mode is enabled or not for an output channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
hal_tim_oc_channel_fast_mode_status_t – Fast Mode status.
-
hal_status_t
HAL_TIM_OC_StartChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s output channel in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StopChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s output channel that was started in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StartChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s output channel in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StopChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s output channel that was started in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_OC_StartChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start a timer’s Output Channel in DMA mode (default DMA interrupts).
Note
One data will be transferred from the buffer to the compare register (TIMx_CCRy) at each compare match.
DMA transfer ends when all the data of the buffer have been transferred.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in byte).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_OC_StartChannel_DMA_Opt
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
-
Start a timer’s Output Channel in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the buffer to the compare register (TIMx_CCRy) at each compare match.
DMA transfer ends when all the data of the buffer have been transferred.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Output channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in byte).
-
interrupts –
Selection of the DMA interrupts.
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_OC_StopChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s output channel that was started in DMA mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Output Channel of interest.
-
- Return values :
-
HAL_OK –
-
hal_tim_oc_compare_unit_t
hal_tim_oc_channel_to_compare_unit
(
hal_tim_channel_t
channel
)
-
Helper function to get a compare unit from an output channel.
- Parameters :
-
channel –
Output channel.
Must be one of the following values:
- Return values :
-
hal_tim_oc_compare_unit_t – Compare unit corresponding to the output channel.
-
Timer Input Channel functions ¶
- group TIM_Exported_Functions_Group5
-
This group contains the functions used to configure and control the input stage of the timer’s capture/compare channels.
The input stage of a timer can be used to
-
inject an external clock
-
detect a trigger
-
measure the period and duty cycle of a PWM signal
-
interface with an incremental (quadrature) decoder
-
interface with a hall sensor
The configuration of an input stage includes:
-
selection of a channel input source
-
selection of the input polarity
-
selection of the filter
-
configuration of the capture unit
-
input capture source selection
-
capture prescaler setting
-
Control functions enable or disable the timer’s input channel.
Three execution modes are proposed:
-
polling
Neither capture interrupt nor capture DMA request are enabled.
It is up to the application to read/clear the capture flag if needed. -
interrupt mode
Capture interrupt is enabled for the concerned channel.
-
DMA
A DMA transfer is started in interrupt mode and capture DMA request is enabled.
At every capture event, the DMA transfers one word from the capture/compare register to the memory.
Functions
-
hal_status_t
HAL_TIM_IC_SetConfigChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
hal_tim_ic_channel_config_t
*
p_config
)
¶
-
Configure an input channel.
Warning
This function selects the input channel as the source of the associated capture unit (direct).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel to configure.
Must be one of the following values:
-
p_config – Pointer to an input channel configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IC_GetConfigChannel
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_ic_channel_config_t
*
p_config
)
¶
-
Get the configuration of an input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest
Must be one of the following values:
-
p_config – Pointer to an input channel configuration structure.
-
-
hal_status_t
HAL_TIM_IC_SetChannelSource
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_channel_src_t
channel_src
)
¶
-
Configure the source of an input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest
Must be one of the following values:
-
channel_src – Input source for the channel.
-
- Return values :
-
HAL_OK –
-
hal_tim_channel_src_t
HAL_TIM_IC_GetChannelSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Get the source of a input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
hal_tim_channel_src_t – The input source for the channel.
-
hal_status_t
HAL_TIM_IC_SetConfigCaptureUnit
(
hal_tim_handle_t
*
htim
,
hal_tim_ic_capture_unit_t
capture_unit
,
const
hal_tim_ic_capture_unit_config_t
*
p_config
)
¶
-
Configure a capture unit.
Warning
When a channel HAL_TIM_CHANNEL_X has to be configured together with the corresponding capture unit HAL_TIM_IC_CAPTURE_UNIT_X (X = 1,2,3 or 4) then HAL_TIM_IC_SetConfigCaptureUnit(HAL_TIM_IC_CAPTURE_UNIT_X) must be called after HAL_TIM_IC_SetConfigChannel(HAL_TIM_CHANNEL_X). Otherwise, the configuration of the active input in HAL_TIM_IC_SetConfigCaptureUnit() is going to be overwritten by the default setting ( HAL_TIM_IC_DIRECT ) in HAL_TIM_IC_SetConfigChannel() .
Warning
When the adjacent timer input channel is selected as the source of the capture unit (i.e. input channel 1 is captured by capture unit 2) then the polarity of the adjacent input channel is overwritten by this function as per the source field value.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
capture_unit – Identify the capture unit to configure.
-
p_config – Pointer to a capture unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IC_GetConfigCaptureUnit
(
const
hal_tim_handle_t
*
htim
,
hal_tim_ic_capture_unit_t
capture_unit
,
hal_tim_ic_capture_unit_config_t
*
p_config
)
¶
-
Get a capture unit configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
capture_unit – Identify the capture unit.
-
p_config – Pointer to a capture unit configuration structure.
-
-
hal_status_t
HAL_TIM_IC_EnableXORGate
(
hal_tim_handle_t
*
htim
)
¶
-
Enable the XOR gate.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_DisableXORGate
(
hal_tim_handle_t
*
htim
)
¶
-
Disable the XOR gate.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_ic_xor_gate_status_t
HAL_TIM_IC_IsEnabledXORGate
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether XOR gate is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_ic_xor_gate_status_t – XOR gate status of timer.
-
uint32_t
HAL_TIM_IC_ReadChannelCapturedValue
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Read the captured value for an input channel of timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
uint32_t – Captured value
-
hal_status_t
HAL_TIM_IC_StartChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Start a timer’s input channel in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StopChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Stop a timer’s input channel that was started in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StartChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Start a timer’s input channel in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StopChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Stop a timer’s input channel that was started in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StartChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
uint8_t
*
p_data
,
uint32_t
size_byte
)
¶
-
Start a timer’s Input Channel in DMA mode (default DMA interrupts).
Note
One data will be transferred from the capture register (TIMx_CCRy) to the buffer at each capture event.
DMA transfer ends when all the data have been transferred to the buffer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_IC_StartChannel_DMA_Opt
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
¶
-
Start a timer’s Input Channel in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the capture register (TIMx_CCRy) to the buffer at each capture event.
DMA transfer ends when all the data have been transferred to the buffer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
interrupts –
Selection of the DMA interrupts.
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_IC_StopChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Stop a timer’s input channel that was started in DMA mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_tim_ic_capture_unit_t
hal_tim_ic_channel_to_direct_capture_unit
(
hal_tim_channel_t
channel
)
¶
-
Helper function to get a direct capture unit from an input channel.
- Parameters :
-
channel –
Input channel.
Must be one of the following values:
- Return values :
-
hal_tim_ic_capture_unit_t – Capture unit corresponding to the input channel.
-
hal_tim_ic_capture_unit_t
hal_tim_ic_channel_to_indirect_capture_unit
(
hal_tim_channel_t
channel
)
¶
-
Helper function to get an indirect capture unit from an input channel.
- Parameters :
-
channel –
Input channel.
Must be one of the following values:
- Return values :
-
hal_tim_ic_capture_unit_t – Indirect capture unit corresponding to the input channel.
-
- group TIM_Exported_Functions_Group5
-
This group contains the functions used to configure and control the input stage of the timer’s capture/compare channels.
The input stage of a timer can be used to
-
inject an external clock
-
detect a trigger
-
measure the period and duty cycle of a PWM signal
-
interface with an incremental (quadrature) decoder
-
interface with a hall sensor
The configuration of an input stage includes:
-
selection of a channel input source
-
selection of the input polarity
-
selection of the filter
-
configuration of the capture unit
-
input capture source selection
-
capture prescaler setting
-
Control functions enable or disable the timer’s input channel.
Three execution modes are proposed:
-
polling
Neither capture interrupt nor capture DMA request are enabled.
It is up to the application to read/clear the capture flag if needed. -
interrupt mode
Capture interrupt is enabled for the concerned channel.
-
DMA
A DMA transfer is started in interrupt mode and capture DMA request is enabled.
At every capture event, the DMA transfers one word from the capture/compare register to the memory.
Functions
-
hal_status_t
HAL_TIM_IC_SetConfigChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
hal_tim_ic_channel_config_t
*
p_config
)
-
Configure an input channel.
Warning
This function selects the input channel as the source of the associated capture unit (direct).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel to configure.
Must be one of the following values:
-
p_config – Pointer to an input channel configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IC_GetConfigChannel
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_ic_channel_config_t
*
p_config
)
-
Get the configuration of an input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest
Must be one of the following values:
-
p_config – Pointer to an input channel configuration structure.
-
-
hal_status_t
HAL_TIM_IC_SetChannelSource
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_channel_src_t
channel_src
)
-
Configure the source of an input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest
Must be one of the following values:
-
channel_src – Input source for the channel.
-
- Return values :
-
HAL_OK –
-
hal_tim_channel_src_t
HAL_TIM_IC_GetChannelSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Get the source of a input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
hal_tim_channel_src_t – The input source for the channel.
-
hal_status_t
HAL_TIM_IC_SetConfigCaptureUnit
(
hal_tim_handle_t
*
htim
,
hal_tim_ic_capture_unit_t
capture_unit
,
const
hal_tim_ic_capture_unit_config_t
*
p_config
)
-
Configure a capture unit.
Warning
When a channel HAL_TIM_CHANNEL_X has to be configured together with the corresponding capture unit HAL_TIM_IC_CAPTURE_UNIT_X (X = 1,2,3 or 4) then HAL_TIM_IC_SetConfigCaptureUnit(HAL_TIM_IC_CAPTURE_UNIT_X) must be called after HAL_TIM_IC_SetConfigChannel(HAL_TIM_CHANNEL_X). Otherwise, the configuration of the active input in HAL_TIM_IC_SetConfigCaptureUnit() is going to be overwritten by the default setting ( HAL_TIM_IC_DIRECT ) in HAL_TIM_IC_SetConfigChannel() .
Warning
When the adjacent timer input channel is selected as the source of the capture unit (i.e. input channel 1 is captured by capture unit 2) then the polarity of the adjacent input channel is overwritten by this function as per the source field value.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
capture_unit – Identify the capture unit to configure.
-
p_config – Pointer to a capture unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IC_GetConfigCaptureUnit
(
const
hal_tim_handle_t
*
htim
,
hal_tim_ic_capture_unit_t
capture_unit
,
hal_tim_ic_capture_unit_config_t
*
p_config
)
-
Get a capture unit configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
capture_unit – Identify the capture unit.
-
p_config – Pointer to a capture unit configuration structure.
-
-
hal_status_t
HAL_TIM_IC_EnableXORGate
(
hal_tim_handle_t
*
htim
)
-
Enable the XOR gate.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_DisableXORGate
(
hal_tim_handle_t
*
htim
)
-
Disable the XOR gate.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_ic_xor_gate_status_t
HAL_TIM_IC_IsEnabledXORGate
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether XOR gate is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_ic_xor_gate_status_t – XOR gate status of timer.
-
uint32_t
HAL_TIM_IC_ReadChannelCapturedValue
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Read the captured value for an input channel of timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
uint32_t – Captured value
-
hal_status_t
HAL_TIM_IC_StartChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s input channel in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StopChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s input channel that was started in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StartChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s input channel in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StopChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s input channel that was started in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StartChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start a timer’s Input Channel in DMA mode (default DMA interrupts).
Note
One data will be transferred from the capture register (TIMx_CCRy) to the buffer at each capture event.
DMA transfer ends when all the data have been transferred to the buffer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_IC_StartChannel_DMA_Opt
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
-
Start a timer’s Input Channel in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the capture register (TIMx_CCRy) to the buffer at each capture event.
DMA transfer ends when all the data have been transferred to the buffer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
interrupts –
Selection of the DMA interrupts.
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_IC_StopChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s input channel that was started in DMA mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_tim_ic_capture_unit_t
hal_tim_ic_channel_to_direct_capture_unit
(
hal_tim_channel_t
channel
)
-
Helper function to get a direct capture unit from an input channel.
- Parameters :
-
channel –
Input channel.
Must be one of the following values:
- Return values :
-
hal_tim_ic_capture_unit_t – Capture unit corresponding to the input channel.
-
hal_tim_ic_capture_unit_t
hal_tim_ic_channel_to_indirect_capture_unit
(
hal_tim_channel_t
channel
)
-
Helper function to get an indirect capture unit from an input channel.
- Parameters :
-
channel –
Input channel.
Must be one of the following values:
- Return values :
-
hal_tim_ic_capture_unit_t – Indirect capture unit corresponding to the input channel.
-
- group TIM_Exported_Functions_Group5
-
This group contains the functions used to configure and control the input stage of the timer’s capture/compare channels.
The input stage of a timer can be used to
-
inject an external clock
-
detect a trigger
-
measure the period and duty cycle of a PWM signal
-
interface with an incremental (quadrature) decoder
-
interface with a hall sensor
The configuration of an input stage includes:
-
selection of a channel input source
-
selection of the input polarity
-
selection of the filter
-
configuration of the capture unit
-
input capture source selection
-
capture prescaler setting
-
Control functions enable or disable the timer’s input channel.
Three execution modes are proposed:
-
polling
Neither capture interrupt nor capture DMA request are enabled.
It is up to the application to read/clear the capture flag if needed. -
interrupt mode
Capture interrupt is enabled for the concerned channel.
-
DMA
A DMA transfer is started in interrupt mode and capture DMA request is enabled.
At every capture event, the DMA transfers one word from the capture/compare register to the memory.
Functions
-
hal_status_t
HAL_TIM_IC_SetConfigChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
const
hal_tim_ic_channel_config_t
*
p_config
)
-
Configure an input channel.
Warning
This function selects the input channel as the source of the associated capture unit (direct).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel to configure.
Must be one of the following values:
-
p_config – Pointer to an input channel configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IC_GetConfigChannel
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_ic_channel_config_t
*
p_config
)
-
Get the configuration of an input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest
Must be one of the following values:
-
p_config – Pointer to an input channel configuration structure.
-
-
hal_status_t
HAL_TIM_IC_SetChannelSource
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
hal_tim_channel_src_t
channel_src
)
-
Configure the source of an input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest
Must be one of the following values:
-
channel_src – Input source for the channel.
-
- Return values :
-
HAL_OK –
-
hal_tim_channel_src_t
HAL_TIM_IC_GetChannelSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Get the source of a input channel.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
hal_tim_channel_src_t – The input source for the channel.
-
hal_status_t
HAL_TIM_IC_SetConfigCaptureUnit
(
hal_tim_handle_t
*
htim
,
hal_tim_ic_capture_unit_t
capture_unit
,
const
hal_tim_ic_capture_unit_config_t
*
p_config
)
-
Configure a capture unit.
Warning
When a channel HAL_TIM_CHANNEL_X has to be configured together with the corresponding capture unit HAL_TIM_IC_CAPTURE_UNIT_X (X = 1,2,3 or 4) then HAL_TIM_IC_SetConfigCaptureUnit(HAL_TIM_IC_CAPTURE_UNIT_X) must be called after HAL_TIM_IC_SetConfigChannel(HAL_TIM_CHANNEL_X). Otherwise, the configuration of the active input in HAL_TIM_IC_SetConfigCaptureUnit() is going to be overwritten by the default setting ( HAL_TIM_IC_DIRECT ) in HAL_TIM_IC_SetConfigChannel() .
Warning
When the adjacent timer input channel is selected as the source of the capture unit (i.e. input channel 1 is captured by capture unit 2) then the polarity of the adjacent input channel is overwritten by this function as per the source field value.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
capture_unit – Identify the capture unit to configure.
-
p_config – Pointer to a capture unit configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IC_GetConfigCaptureUnit
(
const
hal_tim_handle_t
*
htim
,
hal_tim_ic_capture_unit_t
capture_unit
,
hal_tim_ic_capture_unit_config_t
*
p_config
)
-
Get a capture unit configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
capture_unit – Identify the capture unit.
-
p_config – Pointer to a capture unit configuration structure.
-
-
hal_status_t
HAL_TIM_IC_EnableXORGate
(
hal_tim_handle_t
*
htim
)
-
Enable the XOR gate.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_DisableXORGate
(
hal_tim_handle_t
*
htim
)
-
Disable the XOR gate.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_ic_xor_gate_status_t
HAL_TIM_IC_IsEnabledXORGate
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether XOR gate is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_ic_xor_gate_status_t – XOR gate status of timer.
-
uint32_t
HAL_TIM_IC_ReadChannelCapturedValue
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Read the captured value for an input channel of timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
uint32_t – Captured value
-
hal_status_t
HAL_TIM_IC_StartChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s input channel in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StopChannel
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s input channel that was started in polling mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StartChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Start a timer’s input channel in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StopChannel_IT
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s input channel that was started in interrupt mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_IC_StartChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start a timer’s Input Channel in DMA mode (default DMA interrupts).
Note
One data will be transferred from the capture register (TIMx_CCRy) to the buffer at each capture event.
DMA transfer ends when all the data have been transferred to the buffer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_IC_StartChannel_DMA_Opt
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
,
uint8_t
*
p_data
,
uint32_t
size_byte
,
uint32_t
interrupts
)
-
Start a timer’s Input Channel in DMA mode (optional DMA interrupts).
Note
One data will be transferred from the capture register (TIMx_CCRy) to the buffer at each capture event.
DMA transfer ends when all the data have been transferred to the buffer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
p_data – Pointer to the data buffer.
-
size_byte – Data buffer size (in bytes).
-
interrupts –
Selection of the DMA interrupts.
Can be any of the (meaningful) ored values:
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_IC_StopChannel_DMA
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Stop a timer’s input channel that was started in DMA mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
Input channel of interest.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_tim_ic_capture_unit_t
hal_tim_ic_channel_to_direct_capture_unit
(
hal_tim_channel_t
channel
)
-
Helper function to get a direct capture unit from an input channel.
- Parameters :
-
channel –
Input channel.
Must be one of the following values:
- Return values :
-
hal_tim_ic_capture_unit_t – Capture unit corresponding to the input channel.
-
hal_tim_ic_capture_unit_t
hal_tim_ic_channel_to_indirect_capture_unit
(
hal_tim_channel_t
channel
)
-
Helper function to get an indirect capture unit from an input channel.
- Parameters :
-
channel –
Input channel.
Must be one of the following values:
- Return values :
-
hal_tim_ic_capture_unit_t – Indirect capture unit corresponding to the input channel.
-
Timer One-Pulse functions ¶
- group TIM_Exported_Functions_Group6
-
Functions in this group form the API for the control of the one-pulse mode (single pulse or repetitive).
The one-pulse mode of a timer can be used to generate a pulse with a programmable length after a programmable delay on trigger detection
(hence, an input channel and an output channel have to be configured.)
The control functions to enable/disable the one-pulse mode.
Functions
-
hal_status_t
HAL_TIM_EnableOnePulseMode
(
hal_tim_handle_t
*
htim
)
¶
-
Enable the one-pulse mode of timer (single pulse).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableOnePulseMode
(
hal_tim_handle_t
*
htim
)
¶
-
Disable the one-pulse mode of timer.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_one_pulse_mode_status_t
HAL_TIM_IsEnabledOnePulseMode
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether one-pulse mode is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_one_pulse_mode_status_t – One-pulse mode status.
-
hal_status_t
HAL_TIM_EnableOnePulseMode
(
hal_tim_handle_t
*
htim
)
¶
- group TIM_Exported_Functions_Group6
-
Functions in this group form the API for the control of the one-pulse mode (single pulse or repetitive).
The one-pulse mode of a timer can be used to generate a pulse with a programmable length after a programmable delay on trigger detection
(hence, an input channel and an output channel have to be configured.)
The control functions to enable/disable the one-pulse mode.
Functions
-
hal_status_t
HAL_TIM_EnableOnePulseMode
(
hal_tim_handle_t
*
htim
)
-
Enable the one-pulse mode of timer (single pulse).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableOnePulseMode
(
hal_tim_handle_t
*
htim
)
-
Disable the one-pulse mode of timer.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_one_pulse_mode_status_t
HAL_TIM_IsEnabledOnePulseMode
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether one-pulse mode is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_one_pulse_mode_status_t – One-pulse mode status.
-
hal_status_t
HAL_TIM_EnableOnePulseMode
(
hal_tim_handle_t
*
htim
)
- group TIM_Exported_Functions_Group6
-
Functions in this group form the API for the control of the one-pulse mode (single pulse or repetitive).
The one-pulse mode of a timer can be used to generate a pulse with a programmable length after a programmable delay on trigger detection
(hence, an input channel and an output channel have to be configured.)
The control functions to enable/disable the one-pulse mode.
Functions
-
hal_status_t
HAL_TIM_EnableOnePulseMode
(
hal_tim_handle_t
*
htim
)
-
Enable the one-pulse mode of timer (single pulse).
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableOnePulseMode
(
hal_tim_handle_t
*
htim
)
-
Disable the one-pulse mode of timer.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_one_pulse_mode_status_t
HAL_TIM_IsEnabledOnePulseMode
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether one-pulse mode is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_one_pulse_mode_status_t – One-pulse mode status.
-
hal_status_t
HAL_TIM_EnableOnePulseMode
(
hal_tim_handle_t
*
htim
)
Timer Encoder Index functions ¶
- group TIM_Exported_Functions_Group7
-
Functions in this group form the API for the configuration and control of the encoder index.
Basically, the timer is used to determine a rotor speed/position when a quadrature encoder, connected to the timer’s input channels 1 and 2, is used as an external clock.
The counter can be reset by an index signal coming from the encoder connected to the timer external trigger input (ETR).
The configuration of the encoder index:
-
specifies in which counter direction the index event resets the counter
-
specifies in which AB input configuration the index event resets the counter
-
gated with A and B (i.e. channel 1 and 2)
-
gated with A (or with B)
-
ungated
-
-
index blanking (the Index event can be blanked using TI3 or TI4 input)
During the blanking window, the index events are no longer resetting the counter)
-
specifies if this index is active only the first time or always
The control functions to enable/disable the encoder index.
Functions
-
hal_status_t
HAL_TIM_SetConfigEncoderIndex
(
hal_tim_handle_t
*
htim
,
const
hal_tim_encoder_index_config_t
*
p_config
)
¶
-
Configure the index input.
Note
The index input is a pulse coming from an encoder.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the encoder index configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfigEncoderIndex
(
const
hal_tim_handle_t
*
htim
,
hal_tim_encoder_index_config_t
*
p_config
)
¶
-
Get the configuration of the index input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an encoder index configuration structure.
-
-
hal_status_t
HAL_TIM_EnableEncoderIndex
(
hal_tim_handle_t
*
htim
)
¶
-
Enable the index input.
Note
when the index input is enabled, the encoder index signal connected to the timer’s external trigger can reset the counter as per index input configuration.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableEncoderIndex
(
hal_tim_handle_t
*
htim
)
¶
-
Disable the index input.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_encoder_index_status_t
HAL_TIM_IsEnabledEncoderIndex
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether index input is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_encoder_index_status_t – Encoder index status.
-
- group TIM_Exported_Functions_Group7
-
Functions in this group form the API for the configuration and control of the encoder index.
Basically, the timer is used to determine a rotor speed/position when a quadrature encoder, connected to the timer’s input channels 1 and 2, is used as an external clock.
The counter can be reset by an index signal coming from the encoder connected to the timer external trigger input (ETR).
The configuration of the encoder index:
-
specifies in which counter direction the index event resets the counter
-
specifies in which AB input configuration the index event resets the counter
-
gated with A and B (i.e. channel 1 and 2)
-
gated with A (or with B)
-
ungated
-
-
index blanking (the Index event can be blanked using TI3 or TI4 input)
During the blanking window, the index events are no longer resetting the counter)
-
specifies if this index is active only the first time or always
The control functions to enable/disable the encoder index.
Functions
-
hal_status_t
HAL_TIM_SetConfigEncoderIndex
(
hal_tim_handle_t
*
htim
,
const
hal_tim_encoder_index_config_t
*
p_config
)
-
Configure the index input.
Note
The index input is a pulse coming from an encoder.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the encoder index configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfigEncoderIndex
(
const
hal_tim_handle_t
*
htim
,
hal_tim_encoder_index_config_t
*
p_config
)
-
Get the configuration of the index input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an encoder index configuration structure.
-
-
hal_status_t
HAL_TIM_EnableEncoderIndex
(
hal_tim_handle_t
*
htim
)
-
Enable the index input.
Note
when the index input is enabled, the encoder index signal connected to the timer’s external trigger can reset the counter as per index input configuration.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableEncoderIndex
(
hal_tim_handle_t
*
htim
)
-
Disable the index input.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_encoder_index_status_t
HAL_TIM_IsEnabledEncoderIndex
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether index input is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_encoder_index_status_t – Encoder index status.
-
- group TIM_Exported_Functions_Group7
-
Functions in this group form the API for the configuration and control of the encoder index.
Basically, the timer is used to determine a rotor speed/position when a quadrature encoder, connected to the timer’s input channels 1 and 2, is used as an external clock.
The counter can be reset by an index signal coming from the encoder connected to the timer external trigger input (ETR).
The configuration of the encoder index:
-
specifies in which counter direction the index event resets the counter
-
specifies in which AB input configuration the index event resets the counter
-
gated with A and B (i.e. channel 1 and 2)
-
gated with A (or with B)
-
ungated
-
-
index blanking (the Index event can be blanked using TI3 or TI4 input)
During the blanking window, the index events are no longer resetting the counter)
-
specifies if this index is active only the first time or always
The control functions to enable/disable the encoder index.
Functions
-
hal_status_t
HAL_TIM_SetConfigEncoderIndex
(
hal_tim_handle_t
*
htim
,
const
hal_tim_encoder_index_config_t
*
p_config
)
-
Configure the index input.
Note
The index input is a pulse coming from an encoder.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the encoder index configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfigEncoderIndex
(
const
hal_tim_handle_t
*
htim
,
hal_tim_encoder_index_config_t
*
p_config
)
-
Get the configuration of the index input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an encoder index configuration structure.
-
-
hal_status_t
HAL_TIM_EnableEncoderIndex
(
hal_tim_handle_t
*
htim
)
-
Enable the index input.
Note
when the index input is enabled, the encoder index signal connected to the timer’s external trigger can reset the counter as per index input configuration.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableEncoderIndex
(
hal_tim_handle_t
*
htim
)
-
Disable the index input.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_encoder_index_status_t
HAL_TIM_IsEnabledEncoderIndex
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether index input is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_encoder_index_status_t – Encoder index status.
-
Timer External Trigger configuration ¶
- group TIM_Exported_Functions_Group8
-
Functions in this group can be used to configure the external trigger input.
The configuration of the external trigger (ETR) input implies:
-
selection the input source for the ETR
-
selection the input polarity
-
setting of the prescaler
-
setting of the filter
Functions
-
hal_status_t
HAL_TIM_SetExternalTriggerInput
(
hal_tim_handle_t
*
htim
,
const
hal_tim_ext_trig_config_t
*
p_config
)
¶
-
Configure the external trigger input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an external trigger input configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetExternalTriggerInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_ext_trig_config_t
*
p_config
)
¶
-
Get the configuration of the external trigger input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an external trigger input configuration structure.
-
-
- group TIM_Exported_Functions_Group8
-
Functions in this group can be used to configure the external trigger input.
The configuration of the external trigger (ETR) input implies:
-
selection the input source for the ETR
-
selection the input polarity
-
setting of the prescaler
-
setting of the filter
Functions
-
hal_status_t
HAL_TIM_SetExternalTriggerInput
(
hal_tim_handle_t
*
htim
,
const
hal_tim_ext_trig_config_t
*
p_config
)
-
Configure the external trigger input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an external trigger input configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetExternalTriggerInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_ext_trig_config_t
*
p_config
)
-
Get the configuration of the external trigger input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an external trigger input configuration structure.
-
-
- group TIM_Exported_Functions_Group8
-
Functions in this group can be used to configure the external trigger input.
The configuration of the external trigger (ETR) input implies:
-
selection the input source for the ETR
-
selection the input polarity
-
setting of the prescaler
-
setting of the filter
Functions
-
hal_status_t
HAL_TIM_SetExternalTriggerInput
(
hal_tim_handle_t
*
htim
,
const
hal_tim_ext_trig_config_t
*
p_config
)
-
Configure the external trigger input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an external trigger input configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetExternalTriggerInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_ext_trig_config_t
*
p_config
)
-
Get the configuration of the external trigger input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to an external trigger input configuration structure.
-
-
Timer Master/Slave functions ¶
- group TIM_Exported_Functions_Group9
-
Functions in this group form the API for the configuration and control of a timer in master or/and slave mode
(a timer instance can act as both a master and a slave.)
This interface is typically used when one wants to cascade timer instances or to synchronize a timer with the DAC or the ADC.
The slave configuration sets:
-
the slave mode
-
the trigger input to be used to synchronize the counter
The master configuration sets:
-
the trigger output (TRGO and if supported TRGO2)
The control enables/disables:
-
the master/slave mode
When enabled, the effect of an event on the trigger input (trgi) is delayed to allow a perfect synchronization between the current timer and its slaves (through trgo).
It is useful if we want to synchronize several timers on a single external event. -
the slave mode preload
When enabled, the transfer from SMS[3:0] preload to active value is triggered either by the timer’s Update event or Index event.
Functions
-
hal_status_t
HAL_TIM_SetSynchroSlave
(
hal_tim_handle_t
*
htim
,
const
hal_tim_slave_config_t
*
p_config
)
¶
-
Configure the slave mode controller.
Note
The selection of the event triggering the transfer of the preloaded slave mode configuration to the active register is done with HAL_TIM_EnableSlaveModePreload() .
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a slave mode controller configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetSynchroSlave
(
const
hal_tim_handle_t
*
htim
,
hal_tim_slave_config_t
*
p_config
)
¶
-
Get the slave mode controller configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the slave mode controller configuration structure.
-
-
hal_status_t
HAL_TIM_SetTriggerOutput
(
hal_tim_handle_t
*
htim
,
hal_tim_trigger_output_source_t
trgo_src
)
¶
-
Set the trigger output source of master mode controller.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
trgo_src – Trigger-output source.
-
- Return values :
-
HAL_OK –
-
hal_tim_trigger_output_source_t
HAL_TIM_GetTriggerOutput
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the trigger output source of the master mode controller configuration.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_trigger_output_source_t – Trigger-output source.
-
hal_status_t
HAL_TIM_SetTriggerOutput2
(
hal_tim_handle_t
*
htim
,
hal_tim_trigger_output2_source_t
trgo2_src
)
¶
-
Set the trigger output2 source of the master mode controller.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
trgo2_src – Trigger-output2 source.
-
- Return values :
-
HAL_OK –
-
hal_tim_trigger_output2_source_t
HAL_TIM_GetTriggerOutput2
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the trigger output2 source of the master mode controller.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_trigger_output2_source_t – Trigger-output2 source.
-
hal_status_t
HAL_TIM_EnableSlaveModePreload
(
hal_tim_handle_t
*
htim
,
const
hal_tim_slave_mode_preload_src_t
preload_src
)
¶
-
Enable slave mode preload.
Note
When slave mode preload is enabled, slave mode selection (TIMx_SMCR.SMS) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event or at next index event as per chosen slave mode preload source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
preload_src – Slave mode preload source.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableSlaveModePreload
(
hal_tim_handle_t
*
htim
)
¶
-
Disable slave mode preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_slave_mode_preload_status_t
HAL_TIM_IsEnabledSlaveModePreload
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether slave mode preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_slave_mode_preload_status_t – Slave Preload Status.
-
hal_status_t
HAL_TIM_EnableMasterSlaveMode
(
hal_tim_handle_t
*
htim
)
¶
-
Enable master-slave mode.
Note
When the Master/slave mode is enabled, the effect of an event on the trigger input (TRGI) is delayed to allow a perfect synchronization between the current timer and its slaves (through TRGO). It is not mandatory in case of timer synchronization mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableMasterSlaveMode
(
hal_tim_handle_t
*
htim
)
¶
-
Disable master-slave mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_master_slave_mode_status_t
HAL_TIM_IsEnabledMasterSlaveMode
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether Master/Slave mode is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_master_slave_mode_status_t – Master-slave mode status.
-
- group TIM_Exported_Functions_Group9
-
Functions in this group form the API for the configuration and control of a timer in master or/and slave mode
(a timer instance can act as both a master and a slave.)
This interface is typically used when one wants to cascade timer instances or to synchronize a timer with the DAC or the ADC.
The slave configuration sets:
-
the slave mode
-
the trigger input to be used to synchronize the counter
The master configuration sets:
-
the trigger output (TRGO and if supported TRGO2)
The control enables/disables:
-
the master/slave mode
When enabled, the effect of an event on the trigger input (trgi) is delayed to allow a perfect synchronization between the current timer and its slaves (through trgo).
It is useful if we want to synchronize several timers on a single external event. -
the slave mode preload
When enabled, the transfer from SMS[3:0] preload to active value is triggered either by the timer’s Update event or Index event.
Functions
-
hal_status_t
HAL_TIM_SetSynchroSlave
(
hal_tim_handle_t
*
htim
,
const
hal_tim_slave_config_t
*
p_config
)
-
Configure the slave mode controller.
Note
The selection of the event triggering the transfer of the preloaded slave mode configuration to the active register is done with HAL_TIM_EnableSlaveModePreload() .
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a slave mode controller configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetSynchroSlave
(
const
hal_tim_handle_t
*
htim
,
hal_tim_slave_config_t
*
p_config
)
-
Get the slave mode controller configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the slave mode controller configuration structure.
-
-
hal_status_t
HAL_TIM_SetTriggerOutput
(
hal_tim_handle_t
*
htim
,
hal_tim_trigger_output_source_t
trgo_src
)
-
Set the trigger output source of master mode controller.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
trgo_src – Trigger-output source.
-
- Return values :
-
HAL_OK –
-
hal_tim_trigger_output_source_t
HAL_TIM_GetTriggerOutput
(
const
hal_tim_handle_t
*
htim
)
-
Get the trigger output source of the master mode controller configuration.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_trigger_output_source_t – Trigger-output source.
-
hal_status_t
HAL_TIM_SetTriggerOutput2
(
hal_tim_handle_t
*
htim
,
hal_tim_trigger_output2_source_t
trgo2_src
)
-
Set the trigger output2 source of the master mode controller.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
trgo2_src – Trigger-output2 source.
-
- Return values :
-
HAL_OK –
-
hal_tim_trigger_output2_source_t
HAL_TIM_GetTriggerOutput2
(
const
hal_tim_handle_t
*
htim
)
-
Get the trigger output2 source of the master mode controller.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_trigger_output2_source_t – Trigger-output2 source.
-
hal_status_t
HAL_TIM_EnableSlaveModePreload
(
hal_tim_handle_t
*
htim
,
const
hal_tim_slave_mode_preload_src_t
preload_src
)
-
Enable slave mode preload.
Note
When slave mode preload is enabled, slave mode selection (TIMx_SMCR.SMS) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event or at next index event as per chosen slave mode preload source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
preload_src – Slave mode preload source.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableSlaveModePreload
(
hal_tim_handle_t
*
htim
)
-
Disable slave mode preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_slave_mode_preload_status_t
HAL_TIM_IsEnabledSlaveModePreload
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether slave mode preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_slave_mode_preload_status_t – Slave Preload Status.
-
hal_status_t
HAL_TIM_EnableMasterSlaveMode
(
hal_tim_handle_t
*
htim
)
-
Enable master-slave mode.
Note
When the Master/slave mode is enabled, the effect of an event on the trigger input (TRGI) is delayed to allow a perfect synchronization between the current timer and its slaves (through TRGO). It is not mandatory in case of timer synchronization mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableMasterSlaveMode
(
hal_tim_handle_t
*
htim
)
-
Disable master-slave mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_master_slave_mode_status_t
HAL_TIM_IsEnabledMasterSlaveMode
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether Master/Slave mode is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_master_slave_mode_status_t – Master-slave mode status.
-
- group TIM_Exported_Functions_Group9
-
Functions in this group form the API for the configuration and control of a timer in master or/and slave mode
(a timer instance can act as both a master and a slave.)
This interface is typically used when one wants to cascade timer instances or to synchronize a timer with the DAC or the ADC.
The slave configuration sets:
-
the slave mode
-
the trigger input to be used to synchronize the counter
The master configuration sets:
-
the trigger output (TRGO and if supported TRGO2)
The control enables/disables:
-
the master/slave mode
When enabled, the effect of an event on the trigger input (trgi) is delayed to allow a perfect synchronization between the current timer and its slaves (through trgo).
It is useful if we want to synchronize several timers on a single external event. -
the slave mode preload
When enabled, the transfer from SMS[3:0] preload to active value is triggered either by the timer’s Update event or Index event.
Functions
-
hal_status_t
HAL_TIM_SetSynchroSlave
(
hal_tim_handle_t
*
htim
,
const
hal_tim_slave_config_t
*
p_config
)
-
Configure the slave mode controller.
Note
The selection of the event triggering the transfer of the preloaded slave mode configuration to the active register is done with HAL_TIM_EnableSlaveModePreload() .
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a slave mode controller configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetSynchroSlave
(
const
hal_tim_handle_t
*
htim
,
hal_tim_slave_config_t
*
p_config
)
-
Get the slave mode controller configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the slave mode controller configuration structure.
-
-
hal_status_t
HAL_TIM_SetTriggerOutput
(
hal_tim_handle_t
*
htim
,
hal_tim_trigger_output_source_t
trgo_src
)
-
Set the trigger output source of master mode controller.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
trgo_src – Trigger-output source.
-
- Return values :
-
HAL_OK –
-
hal_tim_trigger_output_source_t
HAL_TIM_GetTriggerOutput
(
const
hal_tim_handle_t
*
htim
)
-
Get the trigger output source of the master mode controller configuration.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_trigger_output_source_t – Trigger-output source.
-
hal_status_t
HAL_TIM_SetTriggerOutput2
(
hal_tim_handle_t
*
htim
,
hal_tim_trigger_output2_source_t
trgo2_src
)
-
Set the trigger output2 source of the master mode controller.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
trgo2_src – Trigger-output2 source.
-
- Return values :
-
HAL_OK –
-
hal_tim_trigger_output2_source_t
HAL_TIM_GetTriggerOutput2
(
const
hal_tim_handle_t
*
htim
)
-
Get the trigger output2 source of the master mode controller.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_trigger_output2_source_t – Trigger-output2 source.
-
hal_status_t
HAL_TIM_EnableSlaveModePreload
(
hal_tim_handle_t
*
htim
,
const
hal_tim_slave_mode_preload_src_t
preload_src
)
-
Enable slave mode preload.
Note
When slave mode preload is enabled, slave mode selection (TIMx_SMCR.SMS) preload value isn’t taken into account immediately.
It is loaded in the active register at next update event or at next index event as per chosen slave mode preload source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
preload_src – Slave mode preload source.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableSlaveModePreload
(
hal_tim_handle_t
*
htim
)
-
Disable slave mode preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_slave_mode_preload_status_t
HAL_TIM_IsEnabledSlaveModePreload
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether slave mode preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_slave_mode_preload_status_t – Slave Preload Status.
-
hal_status_t
HAL_TIM_EnableMasterSlaveMode
(
hal_tim_handle_t
*
htim
)
-
Enable master-slave mode.
Note
When the Master/slave mode is enabled, the effect of an event on the trigger input (TRGI) is delayed to allow a perfect synchronization between the current timer and its slaves (through TRGO). It is not mandatory in case of timer synchronization mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableMasterSlaveMode
(
hal_tim_handle_t
*
htim
)
-
Disable master-slave mode.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_master_slave_mode_status_t
HAL_TIM_IsEnabledMasterSlaveMode
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether Master/Slave mode is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_master_slave_mode_status_t – Master-slave mode status.
-
Timer OCRef Clear functions ¶
- group TIM_Exported_Functions_Group10
-
Functions in this group configure and control a timer’s feature known as “OCRef Clear”.
This feature is used to force output compare signals to active or inactive level independently of any comparison between the output compare register and the counter.
The source of the OCRef clear can be external trigger or an internal signal (e.g. comparator output). The configuration consist of:-
selection of the source:
-
external (ETR)
-
internal (COMP1 or COMP2) The control enables/disables the “clear” function for a given channel.
-
Functions
-
hal_status_t
HAL_TIM_SetOCRefClearSource
(
hal_tim_handle_t
*
htim
,
hal_tim_ocrefclear_src_t
source
)
¶
-
Set the OCRef clear source.
Note
This function can only be used in Output compare and PWM modes.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
source – OCRef clear source.
-
- Return values :
-
HAL_OK –
-
hal_tim_ocrefclear_src_t
HAL_TIM_GetOCRefClearSource
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the OCRef clear source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_ocrefclear_src_t – OCRef clear source.
-
hal_status_t
HAL_TIM_EnableChannelOCRefClear
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Enable clearing of the OCxRef signal by the OCRef clear input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableChannelOCRefClear
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Disable clearing of the OCxRef signal by the OCRef clear input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_tim_ocrefclear_status_t
HAL_TIM_IsEnabledChannelOCRefClear
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Tell whether OCxRef signal can be cleared by the OCRef clear input or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
hal_tim_ocrefclear_status_t – OCRefClear status.
-
- group TIM_Exported_Functions_Group10
-
Functions in this group configure and control a timer’s feature known as “OCRef Clear”.
This feature is used to force output compare signals to active or inactive level independently of any comparison between the output compare register and the counter.
The source of the OCRef clear can be external trigger or an internal signal (e.g. comparator output). The configuration consist of:-
selection of the source:
-
external (ETR)
-
internal (COMP1 or COMP2) The control enables/disables the “clear” function for a given channel.
-
Functions
-
hal_status_t
HAL_TIM_SetOCRefClearSource
(
hal_tim_handle_t
*
htim
,
hal_tim_ocrefclear_src_t
source
)
-
Set the OCRef clear source.
Note
This function can only be used in Output compare and PWM modes.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
source – OCRef clear source.
-
- Return values :
-
HAL_OK –
-
hal_tim_ocrefclear_src_t
HAL_TIM_GetOCRefClearSource
(
const
hal_tim_handle_t
*
htim
)
-
Get the OCRef clear source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_ocrefclear_src_t – OCRef clear source.
-
hal_status_t
HAL_TIM_EnableChannelOCRefClear
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Enable clearing of the OCxRef signal by the OCRef clear input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableChannelOCRefClear
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Disable clearing of the OCxRef signal by the OCRef clear input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_tim_ocrefclear_status_t
HAL_TIM_IsEnabledChannelOCRefClear
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Tell whether OCxRef signal can be cleared by the OCRef clear input or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
hal_tim_ocrefclear_status_t – OCRefClear status.
-
- group TIM_Exported_Functions_Group10
-
Functions in this group configure and control a timer’s feature known as “OCRef Clear”.
This feature is used to force output compare signals to active or inactive level independently of any comparison between the output compare register and the counter.
The source of the OCRef clear can be external trigger or an internal signal (e.g. comparator output). The configuration consist of:-
selection of the source:
-
external (ETR)
-
internal (COMP1 or COMP2) The control enables/disables the “clear” function for a given channel.
-
Functions
-
hal_status_t
HAL_TIM_SetOCRefClearSource
(
hal_tim_handle_t
*
htim
,
hal_tim_ocrefclear_src_t
source
)
-
Set the OCRef clear source.
Note
This function can only be used in Output compare and PWM modes.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
source – OCRef clear source.
-
- Return values :
-
HAL_OK –
-
hal_tim_ocrefclear_src_t
HAL_TIM_GetOCRefClearSource
(
const
hal_tim_handle_t
*
htim
)
-
Get the OCRef clear source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_ocrefclear_src_t – OCRef clear source.
-
hal_status_t
HAL_TIM_EnableChannelOCRefClear
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Enable clearing of the OCxRef signal by the OCRef clear input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableChannelOCRefClear
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Disable clearing of the OCxRef signal by the OCRef clear input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
HAL_OK –
-
hal_tim_ocrefclear_status_t
HAL_TIM_IsEnabledChannelOCRefClear
(
const
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Tell whether OCxRef signal can be cleared by the OCRef clear input or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel –
The output channel.
Must be one of the following values:
-
- Return values :
-
hal_tim_ocrefclear_status_t – OCRefClear status.
-
Timer DMA Burst functions ¶
- group TIM_Exported_Functions_Group11
-
Functions in this group configure and control a timer’s feature known as “DMA burst”.
The two main usages of this feature are:
-
DMA burst write: re-program part of the timer peripheral each time a given timer’s event is triggered (e.g. modification on the fly of an output waveform).
-
DMA burts read: read several registers in a row, at regular intervals.
When a DMA burst operation is configured, the application must provide the DMA burst configuration which consist of:
-
Selection of the DMA burst start address
-
Length of the DMA burst
-
Selection of the DMA burst source (triggering event )
When a DMA burst operation is started, the application must provide:
-
Direction of the DMA burst (read or write)
-
Pointer to the data buffer
-
Size (in bytes) of the DMA transfer
The control consist of starting/stopping a DMA burst read/write.
Functions
-
hal_status_t
HAL_TIM_SetConfigDMABurst
(
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_config_t
*
p_config
)
¶
-
Configure the DMA Burst.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the DMA burst configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfigDMABurst
(
const
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_config_t
*
p_config
)
¶
-
Get the DMA Burst configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the DMA burst configuration structure to fill.
-
-
hal_status_t
HAL_TIM_StartDMABurst
(
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_direction_t
dmaburst_direction
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
¶
-
Start the timer DMA Burst operation.
Warning
This function can only be called after DMA burst configuration, i.e. calling HAL_TIM_SetConfigDMABurst() .
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
dmaburst_direction – DMA burst transfer direction.
-
p_data – Pointer to the data buffer.
-
size_byte – Number of byte data to transfer from memory to register.
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_StopDMABurst
(
hal_tim_handle_t
*
htim
)
¶
-
Stop the timer DMA Burst operation.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_dmaburst_base_addr_reg_t
hal_tim_channel_to_dmaburst_base_address
(
hal_tim_channel_t
channel
)
¶
-
Helper function to get the DMA burst base address register for a given channel.
- Parameters :
-
channel –
Channel.
Must be one of the following values:
- Return values :
-
hal_tim_dmaburst_base_addr_reg_t – DMA burst base address register corresponding to the channel.
-
- group TIM_Exported_Functions_Group11
-
Functions in this group configure and control a timer’s feature known as “DMA burst”.
The two main usages of this feature are:
-
DMA burst write: re-program part of the timer peripheral each time a given timer’s event is triggered (e.g. modification on the fly of an output waveform).
-
DMA burts read: read several registers in a row, at regular intervals.
When a DMA burst operation is configured, the application must provide the DMA burst configuration which consist of:
-
Selection of the DMA burst start address
-
Length of the DMA burst
-
Selection of the DMA burst source (triggering event )
When a DMA burst operation is started, the application must provide:
-
Direction of the DMA burst (read or write)
-
Pointer to the data buffer
-
Size (in bytes) of the DMA transfer
The control consist of starting/stopping a DMA burst read/write.
Functions
-
hal_status_t
HAL_TIM_SetConfigDMABurst
(
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_config_t
*
p_config
)
-
Configure the DMA Burst.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the DMA burst configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfigDMABurst
(
const
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_config_t
*
p_config
)
-
Get the DMA Burst configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the DMA burst configuration structure to fill.
-
-
hal_status_t
HAL_TIM_StartDMABurst
(
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_direction_t
dmaburst_direction
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start the timer DMA Burst operation.
Warning
This function can only be called after DMA burst configuration, i.e. calling HAL_TIM_SetConfigDMABurst() .
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
dmaburst_direction – DMA burst transfer direction.
-
p_data – Pointer to the data buffer.
-
size_byte – Number of byte data to transfer from memory to register.
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_StopDMABurst
(
hal_tim_handle_t
*
htim
)
-
Stop the timer DMA Burst operation.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_dmaburst_base_addr_reg_t
hal_tim_channel_to_dmaburst_base_address
(
hal_tim_channel_t
channel
)
-
Helper function to get the DMA burst base address register for a given channel.
- Parameters :
-
channel –
Channel.
Must be one of the following values:
- Return values :
-
hal_tim_dmaburst_base_addr_reg_t – DMA burst base address register corresponding to the channel.
-
- group TIM_Exported_Functions_Group11
-
Functions in this group configure and control a timer’s feature known as “DMA burst”.
The two main usages of this feature are:
-
DMA burst write: re-program part of the timer peripheral each time a given timer’s event is triggered (e.g. modification on the fly of an output waveform).
-
DMA burts read: read several registers in a row, at regular intervals.
When a DMA burst operation is configured, the application must provide the DMA burst configuration which consist of:
-
Selection of the DMA burst start address
-
Length of the DMA burst
-
Selection of the DMA burst source (triggering event )
When a DMA burst operation is started, the application must provide:
-
Direction of the DMA burst (read or write)
-
Pointer to the data buffer
-
Size (in bytes) of the DMA transfer
The control consist of starting/stopping a DMA burst read/write.
Functions
-
hal_status_t
HAL_TIM_SetConfigDMABurst
(
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_config_t
*
p_config
)
-
Configure the DMA Burst.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the DMA burst configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_GetConfigDMABurst
(
const
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_config_t
*
p_config
)
-
Get the DMA Burst configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to the DMA burst configuration structure to fill.
-
-
hal_status_t
HAL_TIM_StartDMABurst
(
hal_tim_handle_t
*
htim
,
hal_tim_dmaburst_direction_t
dmaburst_direction
,
const
uint8_t
*
p_data
,
uint32_t
size_byte
)
-
Start the timer DMA Burst operation.
Warning
This function can only be called after DMA burst configuration, i.e. calling HAL_TIM_SetConfigDMABurst() .
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
dmaburst_direction – DMA burst transfer direction.
-
p_data – Pointer to the data buffer.
-
size_byte – Number of byte data to transfer from memory to register.
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR – Failed to start the DMA transfer.
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_StopDMABurst
(
hal_tim_handle_t
*
htim
)
-
Stop the timer DMA Burst operation.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_dmaburst_base_addr_reg_t
hal_tim_channel_to_dmaburst_base_address
(
hal_tim_channel_t
channel
)
-
Helper function to get the DMA burst base address register for a given channel.
- Parameters :
-
channel –
Channel.
Must be one of the following values:
- Return values :
-
hal_tim_dmaburst_base_addr_reg_t – DMA burst base address register corresponding to the channel.
-
Timer Break functions ¶
- group TIM_Exported_Functions_Group12
-
Functions in this group configure and control the “break” feature that is present on certain timers
(timer peripherals that feature complementary outputs.)
The Break utility acts on the output stage of timer channels configured in output mode.
As soon as an active edge is detected on the break input, the outputs of timer channels configured in output mode are either turned off or forced to a predefined safe state.
With the configuration API one can:
-
for a break input (BKIN or BKIN2)
-
set the polarity
-
set the filter
-
set the alternate function
-
-
for a break input source
-
set the polarity
-
-
set the off state selection in idle and in run mode
With the control API one can:
-
enable/disable a break input (BKIN or BKIN2)
-
rearm a break input (BKIN or BKIN2) when it is configured in bi-directional mode
-
enable/disable a break input source
-
enable/disable the main output
Control all outputs
-
enable/disable the automatic output
Specify whether the main output can only be enabled by software or if it can be automatically re-enabled by hardware at next update event following the break condition disappearance
Functions
-
hal_status_t
HAL_TIM_BREAK_SetConfigInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
const
hal_tim_break_input_config_t
*
p_config
)
¶
-
Configure the break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
p_config – Pointer to the break input configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_BREAK_GetConfigInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_config_t
*
p_config
)
¶
-
Get the configuration of the break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
p_config – Pointer to the break input configuration structure.
-
-
hal_status_t
HAL_TIM_BREAK_SetInputPolarity
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_polarity_t
polarity
)
¶
-
Configure the timer’s break input polarity.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
polarity – Polarity for the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_polarity_t
HAL_TIM_BREAK_GetInputPolarity
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
¶
-
Get the polarity of the timer’s break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
- Return values :
-
hal_tim_break_input_polarity_t – Polarity of the break input.
-
hal_status_t
HAL_TIM_BREAK_SetInputFilter
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_filter_t
filter
)
¶
-
Configure the timer’s break input filter.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
filter – Filter to apply to the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_filter_t
HAL_TIM_BREAK_GetInputFilter
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
¶
-
Get the filter applied to the timer’s break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
- Return values :
-
hal_tim_filter_t – Filter applied to the break input.
-
hal_status_t
HAL_TIM_BREAK_SetInputMode
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_mode_t
mode
)
¶
-
Configure the timer’s break input AF mode (input versus bidirectional).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
mode – Mode (input or bidirectional) for the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_mode_t
HAL_TIM_BREAK_GetInputMode
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
¶
-
Get the timer’s break input mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
- Return values :
-
hal_tim_break_input_mode_dir_t – Break input mode.
-
hal_status_t
HAL_TIM_BREAK_EnableInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
¶
-
Enable a break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to enable.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
¶
-
Disable a break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to disable.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_status_t
HAL_TIM_BREAK_IsEnabledInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
¶
-
Tell whether a break input is enabled or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
- Return values :
-
hal_tim_break_input_status_t – Status of the break input
-
hal_status_t
HAL_TIM_BREAK_RearmInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
¶
-
Re-arm the break input after a break event. This function must be called to re-activate the break circuitry after a break (break2) event.
Note
The system break condition must have disappeared and the system break flag must have been cleared.
Note
If this function succeeds then HAL_TIM_BREAK_EnableMainOutput can be called to re-enable the main output.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to re-arm.
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR –
-
-
hal_status_t
HAL_TIM_BREAK_SetInputSourcePolarity
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
,
hal_tim_break_input_src_polarity_t
polarity
)
¶
-
Configure the break input source polarity.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices. -
polarity – Polarity for the break input source.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_src_polarity_t
HAL_TIM_BREAK_GetInputSourcePolarity
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
¶
-
Get the polarity of the break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
hal_tim_break_input_src_polarity_t – The break input source polarity.
-
hal_status_t
HAL_TIM_BREAK_EnableInputSource
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
¶
-
Enable a break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be a combination of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableInputSource
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
¶
-
Disable a break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be a combination of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_src_status_t
HAL_TIM_BREAK_IsEnabledInputSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
¶
-
Tell whether a break input source is enabled or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
hal_tim_break_input_src_status_t – Break input source status
-
hal_status_t
HAL_TIM_BREAK_EnableMainOutput
(
hal_tim_handle_t
*
htim
)
¶
-
Enable main output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableMainOutput
(
hal_tim_handle_t
*
htim
)
¶
-
Disable main output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_break_main_output_status_t
HAL_TIM_BREAK_IsEnabledMainOutput
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether the main output is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_break_main_output_status_t – Main output status.
-
hal_status_t
HAL_TIM_BREAK_EnableAutomaticOutput
(
hal_tim_handle_t
*
htim
)
¶
-
Enable automatic output.
Note
Main output is cleared by hardware as soon as one of the break inputs is active.
When the break input is not active anymore, main output is automatically set by hardware if automatic output is enabled.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableAutomaticOutput
(
hal_tim_handle_t
*
htim
)
¶
-
Disable automatic output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_break_automatic_output_status_t
HAL_TIM_BREAK_IsEnabledAutomaticOutput
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether the automatic output is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_break_automatic_output_status_t – Status of the automatic output.
-
hal_status_t
HAL_TIM_BREAK_SetOutputOffStates
(
hal_tim_handle_t
*
htim
,
const
hal_tim_off_states_config_t
*
p_config
)
¶
-
Configure the off-state of the timer’s outputs for both RUN mode (when main output is enabled) and IDLE mode (when main output is disabled).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a off states configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_BREAK_GetOutputOffStates
(
const
hal_tim_handle_t
*
htim
,
hal_tim_off_states_config_t
*
p_config
)
¶
-
Get the off-state configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a off states configuration structure.
-
-
- group TIM_Exported_Functions_Group12
-
Functions in this group configure and control the “break” feature that is present on certain timers
(timer peripherals that feature complementary outputs.)
The Break utility acts on the output stage of timer channels configured in output mode.
As soon as an active edge is detected on the break input, the outputs of timer channels configured in output mode are either turned off or forced to a predefined safe state.
With the configuration API one can:
-
for a break input (BKIN or BKIN2)
-
set the polarity
-
set the filter
-
set the alternate function
-
-
for a break input source
-
set the polarity
-
-
set the off state selection in idle and in run mode
With the control API one can:
-
enable/disable a break input (BKIN or BKIN2)
-
rearm a break input (BKIN or BKIN2) when it is configured in bi-directional mode
-
enable/disable a break input source
-
enable/disable the main output
Control all outputs
-
enable/disable the automatic output
Specify whether the main output can only be enabled by software or if it can be automatically re-enabled by hardware at next update event following the break condition disappearance
Functions
-
hal_status_t
HAL_TIM_BREAK_SetConfigInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
const
hal_tim_break_input_config_t
*
p_config
)
-
Configure the break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
p_config – Pointer to the break input configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_BREAK_GetConfigInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_config_t
*
p_config
)
-
Get the configuration of the break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
p_config – Pointer to the break input configuration structure.
-
-
hal_status_t
HAL_TIM_BREAK_SetInputPolarity
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_polarity_t
polarity
)
-
Configure the timer’s break input polarity.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
polarity – Polarity for the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_polarity_t
HAL_TIM_BREAK_GetInputPolarity
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Get the polarity of the timer’s break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
- Return values :
-
hal_tim_break_input_polarity_t – Polarity of the break input.
-
hal_status_t
HAL_TIM_BREAK_SetInputFilter
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_filter_t
filter
)
-
Configure the timer’s break input filter.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
filter – Filter to apply to the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_filter_t
HAL_TIM_BREAK_GetInputFilter
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Get the filter applied to the timer’s break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
- Return values :
-
hal_tim_filter_t – Filter applied to the break input.
-
hal_status_t
HAL_TIM_BREAK_SetInputMode
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_mode_t
mode
)
-
Configure the timer’s break input AF mode (input versus bidirectional).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
mode – Mode (input or bidirectional) for the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_mode_t
HAL_TIM_BREAK_GetInputMode
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Get the timer’s break input mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
- Return values :
-
hal_tim_break_input_mode_dir_t – Break input mode.
-
hal_status_t
HAL_TIM_BREAK_EnableInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Enable a break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to enable.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Disable a break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to disable.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_status_t
HAL_TIM_BREAK_IsEnabledInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Tell whether a break input is enabled or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
- Return values :
-
hal_tim_break_input_status_t – Status of the break input
-
hal_status_t
HAL_TIM_BREAK_RearmInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Re-arm the break input after a break event. This function must be called to re-activate the break circuitry after a break (break2) event.
Note
The system break condition must have disappeared and the system break flag must have been cleared.
Note
If this function succeeds then HAL_TIM_BREAK_EnableMainOutput can be called to re-enable the main output.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to re-arm.
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR –
-
-
hal_status_t
HAL_TIM_BREAK_SetInputSourcePolarity
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
,
hal_tim_break_input_src_polarity_t
polarity
)
-
Configure the break input source polarity.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices. -
polarity – Polarity for the break input source.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_src_polarity_t
HAL_TIM_BREAK_GetInputSourcePolarity
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Get the polarity of the break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
hal_tim_break_input_src_polarity_t – The break input source polarity.
-
hal_status_t
HAL_TIM_BREAK_EnableInputSource
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Enable a break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be a combination of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableInputSource
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Disable a break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be a combination of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_src_status_t
HAL_TIM_BREAK_IsEnabledInputSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Tell whether a break input source is enabled or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
hal_tim_break_input_src_status_t – Break input source status
-
hal_status_t
HAL_TIM_BREAK_EnableMainOutput
(
hal_tim_handle_t
*
htim
)
-
Enable main output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableMainOutput
(
hal_tim_handle_t
*
htim
)
-
Disable main output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_break_main_output_status_t
HAL_TIM_BREAK_IsEnabledMainOutput
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the main output is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_break_main_output_status_t – Main output status.
-
hal_status_t
HAL_TIM_BREAK_EnableAutomaticOutput
(
hal_tim_handle_t
*
htim
)
-
Enable automatic output.
Note
Main output is cleared by hardware as soon as one of the break inputs is active.
When the break input is not active anymore, main output is automatically set by hardware if automatic output is enabled.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableAutomaticOutput
(
hal_tim_handle_t
*
htim
)
-
Disable automatic output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_break_automatic_output_status_t
HAL_TIM_BREAK_IsEnabledAutomaticOutput
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the automatic output is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_break_automatic_output_status_t – Status of the automatic output.
-
hal_status_t
HAL_TIM_BREAK_SetOutputOffStates
(
hal_tim_handle_t
*
htim
,
const
hal_tim_off_states_config_t
*
p_config
)
-
Configure the off-state of the timer’s outputs for both RUN mode (when main output is enabled) and IDLE mode (when main output is disabled).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a off states configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_BREAK_GetOutputOffStates
(
const
hal_tim_handle_t
*
htim
,
hal_tim_off_states_config_t
*
p_config
)
-
Get the off-state configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a off states configuration structure.
-
-
- group TIM_Exported_Functions_Group12
-
Functions in this group configure and control the “break” feature that is present on certain timers
(timer peripherals that feature complementary outputs.)
The Break utility acts on the output stage of timer channels configured in output mode.
As soon as an active edge is detected on the break input, the outputs of timer channels configured in output mode are either turned off or forced to a predefined safe state.
With the configuration API one can:
-
for a break input (BKIN or BKIN2)
-
set the polarity
-
set the filter
-
set the alternate function
-
-
for a break input source
-
set the polarity
-
-
set the off state selection in idle and in run mode
With the control API one can:
-
enable/disable a break input (BKIN or BKIN2)
-
rearm a break input (BKIN or BKIN2) when it is configured in bi-directional mode
-
enable/disable a break input source
-
enable/disable the main output
Control all outputs
-
enable/disable the automatic output
Specify whether the main output can only be enabled by software or if it can be automatically re-enabled by hardware at next update event following the break condition disappearance
Functions
-
hal_status_t
HAL_TIM_BREAK_SetConfigInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
const
hal_tim_break_input_config_t
*
p_config
)
-
Configure the break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
p_config – Pointer to the break input configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_BREAK_GetConfigInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_config_t
*
p_config
)
-
Get the configuration of the break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
p_config – Pointer to the break input configuration structure.
-
-
hal_status_t
HAL_TIM_BREAK_SetInputPolarity
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_polarity_t
polarity
)
-
Configure the timer’s break input polarity.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
polarity – Polarity for the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_polarity_t
HAL_TIM_BREAK_GetInputPolarity
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Get the polarity of the timer’s break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
- Return values :
-
hal_tim_break_input_polarity_t – Polarity of the break input.
-
hal_status_t
HAL_TIM_BREAK_SetInputFilter
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_filter_t
filter
)
-
Configure the timer’s break input filter.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
filter – Filter to apply to the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_filter_t
HAL_TIM_BREAK_GetInputFilter
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Get the filter applied to the timer’s break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
- Return values :
-
hal_tim_filter_t – Filter applied to the break input.
-
hal_status_t
HAL_TIM_BREAK_SetInputMode
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
hal_tim_break_input_mode_t
mode
)
-
Configure the timer’s break input AF mode (input versus bidirectional).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
mode – Mode (input or bidirectional) for the break input.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_mode_t
HAL_TIM_BREAK_GetInputMode
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Get the timer’s break input mode.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
- Return values :
-
hal_tim_break_input_mode_dir_t – Break input mode.
-
hal_status_t
HAL_TIM_BREAK_EnableInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Enable a break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to enable.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Disable a break input.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to disable.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_status_t
HAL_TIM_BREAK_IsEnabledInput
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Tell whether a break input is enabled or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
- Return values :
-
hal_tim_break_input_status_t – Status of the break input
-
hal_status_t
HAL_TIM_BREAK_RearmInput
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
)
-
Re-arm the break input after a break event. This function must be called to re-activate the break circuitry after a break (break2) event.
Note
The system break condition must have disappeared and the system break flag must have been cleared.
Note
If this function succeeds then HAL_TIM_BREAK_EnableMainOutput can be called to re-enable the main output.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to re-arm.
-
- Return values :
-
-
HAL_OK –
-
HAL_ERROR –
-
-
hal_status_t
HAL_TIM_BREAK_SetInputSourcePolarity
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
,
hal_tim_break_input_src_polarity_t
polarity
)
-
Configure the break input source polarity.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input to configure.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices. -
polarity – Polarity for the break input source.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_src_polarity_t
HAL_TIM_BREAK_GetInputSourcePolarity
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Get the polarity of the break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input of interest.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
hal_tim_break_input_src_polarity_t – The break input source polarity.
-
hal_status_t
HAL_TIM_BREAK_EnableInputSource
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Enable a break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be a combination of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableInputSource
(
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Disable a break input source.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be a combination of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
HAL_OK –
-
hal_tim_break_input_src_status_t
HAL_TIM_BREAK_IsEnabledInputSource
(
const
hal_tim_handle_t
*
htim
,
hal_tim_break_input_id_t
brkin
,
uint32_t
brkinsrc
)
-
Tell whether a break input source is enabled or not.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
brkin – The break input.
-
brkinsrc – This parameter can be one of the following values:
(*) Value not defined in all devices.
-
- Return values :
-
hal_tim_break_input_src_status_t – Break input source status
-
hal_status_t
HAL_TIM_BREAK_EnableMainOutput
(
hal_tim_handle_t
*
htim
)
-
Enable main output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableMainOutput
(
hal_tim_handle_t
*
htim
)
-
Disable main output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_break_main_output_status_t
HAL_TIM_BREAK_IsEnabledMainOutput
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the main output is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_break_main_output_status_t – Main output status.
-
hal_status_t
HAL_TIM_BREAK_EnableAutomaticOutput
(
hal_tim_handle_t
*
htim
)
-
Enable automatic output.
Note
Main output is cleared by hardware as soon as one of the break inputs is active.
When the break input is not active anymore, main output is automatically set by hardware if automatic output is enabled.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_BREAK_DisableAutomaticOutput
(
hal_tim_handle_t
*
htim
)
-
Disable automatic output.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_break_automatic_output_status_t
HAL_TIM_BREAK_IsEnabledAutomaticOutput
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the automatic output is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_break_automatic_output_status_t – Status of the automatic output.
-
hal_status_t
HAL_TIM_BREAK_SetOutputOffStates
(
hal_tim_handle_t
*
htim
,
const
hal_tim_off_states_config_t
*
p_config
)
-
Configure the off-state of the timer’s outputs for both RUN mode (when main output is enabled) and IDLE mode (when main output is disabled).
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a off states configuration structure.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – Input parameter is invalid (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_BREAK_GetOutputOffStates
(
const
hal_tim_handle_t
*
htim
,
hal_tim_off_states_config_t
*
p_config
)
-
Get the off-state configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_config – Pointer to a off states configuration structure.
-
-
Timer Deadtime functions ¶
- group TIM_Exported_Functions_Group13
-
Functions in this group configure and control the “deadtime” feature.
Dead-time manages the switching-off and the switching-on instants of the outputs of two complementary signals.
Configuration:
-
set the deadtime for the rising edge
-
set the deadtime for the falling edge
Control:
-
When enabled, the transfer from DTG(F) preload to active value is triggered by the timer’s Update event.
Functions
-
hal_status_t
HAL_TIM_SetDeadtime
(
hal_tim_handle_t
*
htim
,
uint32_t
rising_edge_deadtime
,
uint32_t
falling_edge_deadtime
)
¶
-
Configure the deadtime inserted between two complementary outputs.
Note
For asymmetrical deadtime HAL_TIM_EnableAsymmetricalDeadTime must be called.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
rising_edge_deadtime – Deadtime value for rising edge (number between 0x00 and 0xFF)
-
falling_edge_deadtime – Deadtime value for falling edge (number between 0x00 and 0xFF)
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_GetDeadtime
(
const
hal_tim_handle_t
*
htim
,
uint32_t
*
p_rising_edge_deadtime
,
uint32_t
*
p_falling_edge_deadtime
)
¶
-
Get the deadtime configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_rising_edge_deadtime – Pointer to a storage for the deadtime value for rising edge (number between 0x00 and 0xFF).
-
p_falling_edge_deadtime – Pointer to a storage for the deadtime value for falling edge (number between 0x00 and 0xFF).
-
-
hal_status_t
HAL_TIM_EnableDeadtimePreload
(
hal_tim_handle_t
*
htim
)
¶
-
Enable the deadtime configuration preload (DTG[7:0] and DTGF[7:0] bitfields).
Note
When deadtime preload is enabled, rising and falling deatime (TIMx_BDTR.DTG and TIMx_DTR2.DTGF) preload values aren’t taken into account immediately.
They are loaded in the active register at next update event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableDeadtimePreload
(
hal_tim_handle_t
*
htim
)
¶
-
Disable the deadtime configuration preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_deadtime_preload_status_t
HAL_TIM_IsEnabledDeadtimePreload
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether the deadtime configuration preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_deadtime_preload_status_t – Deadtime preload status.
-
hal_status_t
HAL_TIM_EnableAsymmetricalDeadtime
(
hal_tim_handle_t
*
htim
)
¶
-
Enable asymmetrical deadtime.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableAsymmetricalDeadtime
(
hal_tim_handle_t
*
htim
)
¶
-
Disable asymmetrical deadtime.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_asymmetrical_deadtime_status_t
HAL_TIM_IsEnabledAsymmetricalDeadtime
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether asymmetrical deadtime is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Returns :
-
hal_tim_asymmetrical_deadtime_status_t Asymmetrical deadtime status.
-
- group TIM_Exported_Functions_Group13
-
Functions in this group configure and control the “deadtime” feature.
Dead-time manages the switching-off and the switching-on instants of the outputs of two complementary signals.
Configuration:
-
set the deadtime for the rising edge
-
set the deadtime for the falling edge
Control:
-
When enabled, the transfer from DTG(F) preload to active value is triggered by the timer’s Update event.
Functions
-
hal_status_t
HAL_TIM_SetDeadtime
(
hal_tim_handle_t
*
htim
,
uint32_t
rising_edge_deadtime
,
uint32_t
falling_edge_deadtime
)
-
Configure the deadtime inserted between two complementary outputs.
Note
For asymmetrical deadtime HAL_TIM_EnableAsymmetricalDeadTime must be called.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
rising_edge_deadtime – Deadtime value for rising edge (number between 0x00 and 0xFF)
-
falling_edge_deadtime – Deadtime value for falling edge (number between 0x00 and 0xFF)
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_GetDeadtime
(
const
hal_tim_handle_t
*
htim
,
uint32_t
*
p_rising_edge_deadtime
,
uint32_t
*
p_falling_edge_deadtime
)
-
Get the deadtime configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_rising_edge_deadtime – Pointer to a storage for the deadtime value for rising edge (number between 0x00 and 0xFF).
-
p_falling_edge_deadtime – Pointer to a storage for the deadtime value for falling edge (number between 0x00 and 0xFF).
-
-
hal_status_t
HAL_TIM_EnableDeadtimePreload
(
hal_tim_handle_t
*
htim
)
-
Enable the deadtime configuration preload (DTG[7:0] and DTGF[7:0] bitfields).
Note
When deadtime preload is enabled, rising and falling deatime (TIMx_BDTR.DTG and TIMx_DTR2.DTGF) preload values aren’t taken into account immediately.
They are loaded in the active register at next update event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableDeadtimePreload
(
hal_tim_handle_t
*
htim
)
-
Disable the deadtime configuration preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_deadtime_preload_status_t
HAL_TIM_IsEnabledDeadtimePreload
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the deadtime configuration preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_deadtime_preload_status_t – Deadtime preload status.
-
hal_status_t
HAL_TIM_EnableAsymmetricalDeadtime
(
hal_tim_handle_t
*
htim
)
-
Enable asymmetrical deadtime.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableAsymmetricalDeadtime
(
hal_tim_handle_t
*
htim
)
-
Disable asymmetrical deadtime.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_asymmetrical_deadtime_status_t
HAL_TIM_IsEnabledAsymmetricalDeadtime
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether asymmetrical deadtime is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Returns :
-
hal_tim_asymmetrical_deadtime_status_t Asymmetrical deadtime status.
-
- group TIM_Exported_Functions_Group13
-
Functions in this group configure and control the “deadtime” feature.
Dead-time manages the switching-off and the switching-on instants of the outputs of two complementary signals.
Configuration:
-
set the deadtime for the rising edge
-
set the deadtime for the falling edge
Control:
-
When enabled, the transfer from DTG(F) preload to active value is triggered by the timer’s Update event.
Functions
-
hal_status_t
HAL_TIM_SetDeadtime
(
hal_tim_handle_t
*
htim
,
uint32_t
rising_edge_deadtime
,
uint32_t
falling_edge_deadtime
)
-
Configure the deadtime inserted between two complementary outputs.
Note
For asymmetrical deadtime HAL_TIM_EnableAsymmetricalDeadTime must be called.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
rising_edge_deadtime – Deadtime value for rising edge (number between 0x00 and 0xFF)
-
falling_edge_deadtime – Deadtime value for falling edge (number between 0x00 and 0xFF)
-
- Return values :
-
HAL_OK –
-
void
HAL_TIM_GetDeadtime
(
const
hal_tim_handle_t
*
htim
,
uint32_t
*
p_rising_edge_deadtime
,
uint32_t
*
p_falling_edge_deadtime
)
-
Get the deadtime configuration.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_rising_edge_deadtime – Pointer to a storage for the deadtime value for rising edge (number between 0x00 and 0xFF).
-
p_falling_edge_deadtime – Pointer to a storage for the deadtime value for falling edge (number between 0x00 and 0xFF).
-
-
hal_status_t
HAL_TIM_EnableDeadtimePreload
(
hal_tim_handle_t
*
htim
)
-
Enable the deadtime configuration preload (DTG[7:0] and DTGF[7:0] bitfields).
Note
When deadtime preload is enabled, rising and falling deatime (TIMx_BDTR.DTG and TIMx_DTR2.DTGF) preload values aren’t taken into account immediately.
They are loaded in the active register at next update event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableDeadtimePreload
(
hal_tim_handle_t
*
htim
)
-
Disable the deadtime configuration preload.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_deadtime_preload_status_t
HAL_TIM_IsEnabledDeadtimePreload
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the deadtime configuration preload is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_deadtime_preload_status_t – Deadtime preload status.
-
hal_status_t
HAL_TIM_EnableAsymmetricalDeadtime
(
hal_tim_handle_t
*
htim
)
-
Enable asymmetrical deadtime.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableAsymmetricalDeadtime
(
hal_tim_handle_t
*
htim
)
-
Disable asymmetrical deadtime.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_asymmetrical_deadtime_status_t
HAL_TIM_IsEnabledAsymmetricalDeadtime
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether asymmetrical deadtime is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Returns :
-
hal_tim_asymmetrical_deadtime_status_t Asymmetrical deadtime status.
-
Timer Protection ¶
- group TIM_Exported_Functions_Group14
-
This group contains only two functions that are the setter and getter of the lock level.
The lock feature is a write protection that freezes the configuration of safety critical parameters (e.g. break inputs and deadtime configuration).
Functions
-
hal_status_t
HAL_TIM_SetLockLevel
(
hal_tim_handle_t
*
htim
,
hal_tim_lock_level_t
lock_level
)
¶
-
Set the timer lock level.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
lock_level – Lock level.
-
- Return values :
-
HAL_OK –
-
hal_tim_lock_level_t
HAL_TIM_GetLockLevel
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the timer lock level.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_lock_level_t – Lock level.
-
hal_status_t
HAL_TIM_SetLockLevel
(
hal_tim_handle_t
*
htim
,
hal_tim_lock_level_t
lock_level
)
¶
- group TIM_Exported_Functions_Group14
-
This group contains only two functions that are the setter and getter of the lock level.
The lock feature is a write protection that freezes the configuration of safety critical parameters (e.g. break inputs and deadtime configuration).
Functions
-
hal_status_t
HAL_TIM_SetLockLevel
(
hal_tim_handle_t
*
htim
,
hal_tim_lock_level_t
lock_level
)
-
Set the timer lock level.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
lock_level – Lock level.
-
- Return values :
-
HAL_OK –
-
hal_tim_lock_level_t
HAL_TIM_GetLockLevel
(
const
hal_tim_handle_t
*
htim
)
-
Get the timer lock level.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_lock_level_t – Lock level.
-
hal_status_t
HAL_TIM_SetLockLevel
(
hal_tim_handle_t
*
htim
,
hal_tim_lock_level_t
lock_level
)
- group TIM_Exported_Functions_Group14
-
This group contains only two functions that are the setter and getter of the lock level.
The lock feature is a write protection that freezes the configuration of safety critical parameters (e.g. break inputs and deadtime configuration).
Functions
-
hal_status_t
HAL_TIM_SetLockLevel
(
hal_tim_handle_t
*
htim
,
hal_tim_lock_level_t
lock_level
)
-
Set the timer lock level.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
lock_level – Lock level.
-
- Return values :
-
HAL_OK –
-
hal_tim_lock_level_t
HAL_TIM_GetLockLevel
(
const
hal_tim_handle_t
*
htim
)
-
Get the timer lock level.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_lock_level_t – Lock level.
-
hal_status_t
HAL_TIM_SetLockLevel
(
hal_tim_handle_t
*
htim
,
hal_tim_lock_level_t
lock_level
)
Timer Commutation control ¶
- group TIM_Exported_Functions_Group15
-
This group contains functions required to manage the commutation feature.
The commutation feature is used in combination with the preload mechanism to change the timer channel configuration (e.g. output mode, channel enabled/disabled)
in perfect synchronization with timer external events generated by software or through a trigger input (internal (ITRx) or external (ETR, TI1, or TI2)).
When the commutation feature is enabled, capture/compare control bits (CCxE, CCxNE and OCxM) are preloaded and
the commutation event trigger is set as per application’s choice (software and/or trigger input).Functions
-
hal_status_t
HAL_TIM_EnableCommutation
(
hal_tim_handle_t
*
htim
,
hal_tim_commutation_src_t
commutation_source
)
¶
-
Enable the commutation and set the commutation event source.
Note
when commutation is enabled, CCxE, CCxNE and OCxM bit are preloaded.
They are loaded in the active register when the commutation event occurs.
Commutation event can be triggered by software or both by software and trigger input as per chosen commutation source.- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
commutation_source – Commutation source.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableCommutation
(
hal_tim_handle_t
*
htim
)
¶
-
Disable the commutation feature.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_commutation_status_t
HAL_TIM_IsEnabledCommutation
(
const
hal_tim_handle_t
*
htim
)
¶
-
Tell whether the commutation is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_commutation_status_t – Status (Enabled/Disabled) of the commutation feature.
-
hal_tim_commutation_src_t
HAL_TIM_GetCommutationSource
(
const
hal_tim_handle_t
*
htim
)
¶
-
Get the commutation event source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_commutation_src_t – Source (software only or software and trigger input) of the commutation feature.
-
hal_status_t
HAL_TIM_EnableCommutation
(
hal_tim_handle_t
*
htim
,
hal_tim_commutation_src_t
commutation_source
)
¶
- group TIM_Exported_Functions_Group15
-
This group contains functions required to manage the commutation feature.
The commutation feature is used in combination with the preload mechanism to change the timer channel configuration (e.g. output mode, channel enabled/disabled)
in perfect synchronization with timer external events generated by software or through a trigger input (internal (ITRx) or external (ETR, TI1, or TI2)).
When the commutation feature is enabled, capture/compare control bits (CCxE, CCxNE and OCxM) are preloaded and
the commutation event trigger is set as per application’s choice (software and/or trigger input).Functions
-
hal_status_t
HAL_TIM_EnableCommutation
(
hal_tim_handle_t
*
htim
,
hal_tim_commutation_src_t
commutation_source
)
-
Enable the commutation and set the commutation event source.
Note
when commutation is enabled, CCxE, CCxNE and OCxM bit are preloaded.
They are loaded in the active register when the commutation event occurs.
Commutation event can be triggered by software or both by software and trigger input as per chosen commutation source.- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
commutation_source – Commutation source.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableCommutation
(
hal_tim_handle_t
*
htim
)
-
Disable the commutation feature.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_commutation_status_t
HAL_TIM_IsEnabledCommutation
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the commutation is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_commutation_status_t – Status (Enabled/Disabled) of the commutation feature.
-
hal_tim_commutation_src_t
HAL_TIM_GetCommutationSource
(
const
hal_tim_handle_t
*
htim
)
-
Get the commutation event source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_commutation_src_t – Source (software only or software and trigger input) of the commutation feature.
-
hal_status_t
HAL_TIM_EnableCommutation
(
hal_tim_handle_t
*
htim
,
hal_tim_commutation_src_t
commutation_source
)
- group TIM_Exported_Functions_Group15
-
This group contains functions required to manage the commutation feature.
The commutation feature is used in combination with the preload mechanism to change the timer channel configuration (e.g. output mode, channel enabled/disabled)
in perfect synchronization with timer external events generated by software or through a trigger input (internal (ITRx) or external (ETR, TI1, or TI2)).
When the commutation feature is enabled, capture/compare control bits (CCxE, CCxNE and OCxM) are preloaded and
the commutation event trigger is set as per application’s choice (software and/or trigger input).Functions
-
hal_status_t
HAL_TIM_EnableCommutation
(
hal_tim_handle_t
*
htim
,
hal_tim_commutation_src_t
commutation_source
)
-
Enable the commutation and set the commutation event source.
Note
when commutation is enabled, CCxE, CCxNE and OCxM bit are preloaded.
They are loaded in the active register when the commutation event occurs.
Commutation event can be triggered by software or both by software and trigger input as per chosen commutation source.- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
commutation_source – Commutation source.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_DisableCommutation
(
hal_tim_handle_t
*
htim
)
-
Disable the commutation feature.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
HAL_OK –
-
hal_tim_commutation_status_t
HAL_TIM_IsEnabledCommutation
(
const
hal_tim_handle_t
*
htim
)
-
Tell whether the commutation is enabled or not.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_commutation_status_t – Status (Enabled/Disabled) of the commutation feature.
-
hal_tim_commutation_src_t
HAL_TIM_GetCommutationSource
(
const
hal_tim_handle_t
*
htim
)
-
Get the commutation event source.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
hal_tim_commutation_src_t – Source (software only or software and trigger input) of the commutation feature.
-
hal_status_t
HAL_TIM_EnableCommutation
(
hal_tim_handle_t
*
htim
,
hal_tim_commutation_src_t
commutation_source
)
Timer SW Event Generation ¶
- group TIM_Exported_Functions_Group16
-
This group contains only one function that is used to control, by software, the generation of a timer’s event.
Functions
-
hal_status_t
HAL_TIM_GenerateEvent
(
hal_tim_handle_t
*
htim
,
hal_tim_sw_event_id_t
sw_event_id
)
¶
-
Generate a software event for the timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
sw_event_id – The source of the event.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_GenerateEvent
(
hal_tim_handle_t
*
htim
,
hal_tim_sw_event_id_t
sw_event_id
)
¶
- group TIM_Exported_Functions_Group16
-
This group contains only one function that is used to control, by software, the generation of a timer’s event.
Functions
-
hal_status_t
HAL_TIM_GenerateEvent
(
hal_tim_handle_t
*
htim
,
hal_tim_sw_event_id_t
sw_event_id
)
-
Generate a software event for the timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
sw_event_id – The source of the event.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_GenerateEvent
(
hal_tim_handle_t
*
htim
,
hal_tim_sw_event_id_t
sw_event_id
)
- group TIM_Exported_Functions_Group16
-
This group contains only one function that is used to control, by software, the generation of a timer’s event.
Functions
-
hal_status_t
HAL_TIM_GenerateEvent
(
hal_tim_handle_t
*
htim
,
hal_tim_sw_event_id_t
sw_event_id
)
-
Generate a software event for the timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
sw_event_id – The source of the event.
-
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_TIM_GenerateEvent
(
hal_tim_handle_t
*
htim
,
hal_tim_sw_event_id_t
sw_event_id
)
Timer IRQ Handler and Callbacks functions ¶
- group TIM_Exported_Functions_Group17
-
Functions
-
void
HAL_TIM_IRQHandler
(
hal_tim_handle_t
*
htim
)
¶
-
This function handles TIM generic interrupts requests.
Note
Handle all the timer interrupt requests.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_UPD_IRQHandler
(
hal_tim_handle_t
*
htim
)
¶
-
Timer update interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_CC_IRQHandler
(
hal_tim_handle_t
*
htim
)
¶
-
Timer Capture/Compare interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_BRK_TERR_IERR_IRQHandler
(
hal_tim_handle_t
*
htim
)
¶
-
Timer Break, Transition error and Index error interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TRGI_COM_DIR_IDX_IRQHandler
(
hal_tim_handle_t
*
htim
)
¶
-
Timer Trigger, Commutation, Direction change and Index interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_ErrorCallback
(
hal_tim_handle_t
*
htim
)
¶
-
DMA Error callback
This function is called in case of a DMA transfer error.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_StopCallback
(
hal_tim_handle_t
*
htim
)
¶
-
DMA Stop callback
This function is called after stopping a DMA transfer either triggered by the timer update event, the commutation event or the trigger event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_ChannelStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
DMA Channel Stop callback
This function is called after stopping a DMA transfer triggered by a capture/compare event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel stopped for the capture/compare.
-
-
void
HAL_TIM_UpdateCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Update callback.
Function called when the timer update interrupt is generated or when the DMA transfer triggered by the timer update DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_UpdateHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Update Half Complete callback.
Function called when the DMA transfer triggered by the timer update DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TriggerCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Trigger callback.
Function called when the timer trigger interrupt is generated or when the DMA transfer triggered by the timer trigger DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TriggerHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Trigger Half Complete callback.
Function called when the DMA transfer triggered by the timer trigger DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_InputCaptureCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Input Capture callback.
Function called when an input capture interrupt is generated or when the DMA transfer triggered by the an input capture DMA request is completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the input capture.
-
-
void
HAL_TIM_InputCaptureHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Input Capture Half Complete callback.
Function called when the DMA transfer triggered by an input capture DMA request is half completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the input capture.
-
-
void
HAL_TIM_CompareMatchCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Compare Match callback.
Function called when a compare match interrupt is generated or when the DMA transfer triggered by the compare match DMA request is completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the output compare.
-
-
void
HAL_TIM_CompareMatchHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
¶
-
Compare Match Half Complete callback.
Function called when the DMA transfer triggered by compare matche DMA request is half completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the output compare.
-
-
void
HAL_TIM_CommutationCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Commutation callback.
Function called when the timer commutation interrupt is generated or when the DMA transfer triggered by the commutation DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_CommutationHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Commutation Half Complete callback.
Function called when the DMA transfer triggered by the commutation DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_BreakCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Break callback.
Function called when the break interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_Break2Callback
(
hal_tim_handle_t
*
htim
)
¶
-
Break2 callback.
Function called when the break2 interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_SystemBreakCallback
(
hal_tim_handle_t
*
htim
)
¶
-
System Break callback.
Function called when the system break interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_EncoderIndexCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Encoder Index callback.
Could be renamed HAL_TIM_IndexCallback Function called when the index interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_DirectionChangeCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Encoder Direction Change callback.
Function called when the direction change interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_IndexErrorCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Index Error callback.
Function called when the index error interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TransitionErrorCallback
(
hal_tim_handle_t
*
htim
)
¶
-
Transition Error callback.
Function called when the transition error interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
hal_status_t
HAL_TIM_RegisterErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the DMA Error.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the DMA stop callback.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterChannelStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
¶
-
Callback registration for the DMA channel stop callback.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterUpdateCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterUpdateHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the DMA Half Complete transfer triggered on Update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTriggerCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Trigger event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTriggerHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the DMA Half Complete transfer triggered by a Trigger event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterInputCaptureCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
¶
-
Callback registration for the Input Capture event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterInputCaptureHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
¶
-
Callback registration for the DMA Half Complete transfer triggered by an Input Capture event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCompareMatchCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
¶
-
Callback registration for the Compare Match event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCompareMatchHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
¶
-
Callback registration for the Half Complete DMA transfer triggered by a Compare Match event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCommutationCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Commutation event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCommutationHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the DMA Half Complete transfer triggered by a Commutation event. for the timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterBreakCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Break event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterBreak2Callback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Break 2 event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterSystemBreakCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the System Break event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterEncoderIndexCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Encoder Index event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterDirectionChangeCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Encoder Direction Change event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterIndexErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Encoder Index Error event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTransitionErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
¶
-
Callback registration for the Encoder Transition Error event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IRQHandler
(
hal_tim_handle_t
*
htim
)
¶
- group TIM_Exported_Functions_Group17
-
Functions
-
void
HAL_TIM_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
This function handles TIM generic interrupts requests.
Note
Handle all the timer interrupt requests.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_UPD_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer update interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_CC_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer Capture/Compare interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_BRK_TERR_IERR_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer Break, Transition error and Index error interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TRGI_COM_DIR_IDX_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer Trigger, Commutation, Direction change and Index interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_ErrorCallback
(
hal_tim_handle_t
*
htim
)
-
DMA Error callback
This function is called in case of a DMA transfer error.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_StopCallback
(
hal_tim_handle_t
*
htim
)
-
DMA Stop callback
This function is called after stopping a DMA transfer either triggered by the timer update event, the commutation event or the trigger event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_ChannelStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
DMA Channel Stop callback
This function is called after stopping a DMA transfer triggered by a capture/compare event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel stopped for the capture/compare.
-
-
void
HAL_TIM_UpdateCallback
(
hal_tim_handle_t
*
htim
)
-
Update callback.
Function called when the timer update interrupt is generated or when the DMA transfer triggered by the timer update DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_UpdateHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
-
Update Half Complete callback.
Function called when the DMA transfer triggered by the timer update DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TriggerCallback
(
hal_tim_handle_t
*
htim
)
-
Trigger callback.
Function called when the timer trigger interrupt is generated or when the DMA transfer triggered by the timer trigger DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TriggerHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
-
Trigger Half Complete callback.
Function called when the DMA transfer triggered by the timer trigger DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_InputCaptureCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Input Capture callback.
Function called when an input capture interrupt is generated or when the DMA transfer triggered by the an input capture DMA request is completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the input capture.
-
-
void
HAL_TIM_InputCaptureHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Input Capture Half Complete callback.
Function called when the DMA transfer triggered by an input capture DMA request is half completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the input capture.
-
-
void
HAL_TIM_CompareMatchCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Compare Match callback.
Function called when a compare match interrupt is generated or when the DMA transfer triggered by the compare match DMA request is completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the output compare.
-
-
void
HAL_TIM_CompareMatchHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Compare Match Half Complete callback.
Function called when the DMA transfer triggered by compare matche DMA request is half completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the output compare.
-
-
void
HAL_TIM_CommutationCallback
(
hal_tim_handle_t
*
htim
)
-
Commutation callback.
Function called when the timer commutation interrupt is generated or when the DMA transfer triggered by the commutation DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_CommutationHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
-
Commutation Half Complete callback.
Function called when the DMA transfer triggered by the commutation DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_BreakCallback
(
hal_tim_handle_t
*
htim
)
-
Break callback.
Function called when the break interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_Break2Callback
(
hal_tim_handle_t
*
htim
)
-
Break2 callback.
Function called when the break2 interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_SystemBreakCallback
(
hal_tim_handle_t
*
htim
)
-
System Break callback.
Function called when the system break interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_EncoderIndexCallback
(
hal_tim_handle_t
*
htim
)
-
Encoder Index callback.
Could be renamed HAL_TIM_IndexCallback Function called when the index interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_DirectionChangeCallback
(
hal_tim_handle_t
*
htim
)
-
Encoder Direction Change callback.
Function called when the direction change interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_IndexErrorCallback
(
hal_tim_handle_t
*
htim
)
-
Index Error callback.
Function called when the index error interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TransitionErrorCallback
(
hal_tim_handle_t
*
htim
)
-
Transition Error callback.
Function called when the transition error interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
hal_status_t
HAL_TIM_RegisterErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Error.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA stop callback.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterChannelStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the DMA channel stop callback.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterUpdateCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterUpdateHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered on Update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTriggerCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Trigger event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTriggerHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered by a Trigger event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterInputCaptureCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the Input Capture event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterInputCaptureHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered by an Input Capture event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCompareMatchCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the Compare Match event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCompareMatchHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the Half Complete DMA transfer triggered by a Compare Match event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCommutationCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Commutation event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCommutationHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered by a Commutation event. for the timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterBreakCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Break event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterBreak2Callback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Break 2 event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterSystemBreakCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the System Break event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterEncoderIndexCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Index event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterDirectionChangeCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Direction Change event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterIndexErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Index Error event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTransitionErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Transition Error event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IRQHandler
(
hal_tim_handle_t
*
htim
)
- group TIM_Exported_Functions_Group17
-
Functions
-
void
HAL_TIM_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
This function handles TIM generic interrupts requests.
Note
Handle all the timer interrupt requests.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_UPD_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer update interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_CC_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer Capture/Compare interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_BRK_TERR_IERR_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer Break, Transition error and Index error interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TRGI_COM_DIR_IDX_IRQHandler
(
hal_tim_handle_t
*
htim
)
-
Timer Trigger, Commutation, Direction change and Index interrupt handler.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_ErrorCallback
(
hal_tim_handle_t
*
htim
)
-
DMA Error callback
This function is called in case of a DMA transfer error.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_StopCallback
(
hal_tim_handle_t
*
htim
)
-
DMA Stop callback
This function is called after stopping a DMA transfer either triggered by the timer update event, the commutation event or the trigger event.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_ChannelStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
DMA Channel Stop callback
This function is called after stopping a DMA transfer triggered by a capture/compare event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel stopped for the capture/compare.
-
-
void
HAL_TIM_UpdateCallback
(
hal_tim_handle_t
*
htim
)
-
Update callback.
Function called when the timer update interrupt is generated or when the DMA transfer triggered by the timer update DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_UpdateHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
-
Update Half Complete callback.
Function called when the DMA transfer triggered by the timer update DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TriggerCallback
(
hal_tim_handle_t
*
htim
)
-
Trigger callback.
Function called when the timer trigger interrupt is generated or when the DMA transfer triggered by the timer trigger DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TriggerHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
-
Trigger Half Complete callback.
Function called when the DMA transfer triggered by the timer trigger DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_InputCaptureCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Input Capture callback.
Function called when an input capture interrupt is generated or when the DMA transfer triggered by the an input capture DMA request is completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the input capture.
-
-
void
HAL_TIM_InputCaptureHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Input Capture Half Complete callback.
Function called when the DMA transfer triggered by an input capture DMA request is half completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the input capture.
-
-
void
HAL_TIM_CompareMatchCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Compare Match callback.
Function called when a compare match interrupt is generated or when the DMA transfer triggered by the compare match DMA request is completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the output compare.
-
-
void
HAL_TIM_CompareMatchHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_t
channel
)
-
Compare Match Half Complete callback.
Function called when the DMA transfer triggered by compare matche DMA request is half completed.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
channel – Channel for the output compare.
-
-
void
HAL_TIM_CommutationCallback
(
hal_tim_handle_t
*
htim
)
-
Commutation callback.
Function called when the timer commutation interrupt is generated or when the DMA transfer triggered by the commutation DMA request is completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_CommutationHalfCpltCallback
(
hal_tim_handle_t
*
htim
)
-
Commutation Half Complete callback.
Function called when the DMA transfer triggered by the commutation DMA request is half completed.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_BreakCallback
(
hal_tim_handle_t
*
htim
)
-
Break callback.
Function called when the break interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_Break2Callback
(
hal_tim_handle_t
*
htim
)
-
Break2 callback.
Function called when the break2 interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_SystemBreakCallback
(
hal_tim_handle_t
*
htim
)
-
System Break callback.
Function called when the system break interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_EncoderIndexCallback
(
hal_tim_handle_t
*
htim
)
-
Encoder Index callback.
Could be renamed HAL_TIM_IndexCallback Function called when the index interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_DirectionChangeCallback
(
hal_tim_handle_t
*
htim
)
-
Encoder Direction Change callback.
Function called when the direction change interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_IndexErrorCallback
(
hal_tim_handle_t
*
htim
)
-
Index Error callback.
Function called when the index error interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
void
HAL_TIM_TransitionErrorCallback
(
hal_tim_handle_t
*
htim
)
-
Transition Error callback.
Function called when the transition error interrupt is generated.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
-
hal_status_t
HAL_TIM_RegisterErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Error.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA stop callback.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterChannelStopCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the DMA channel stop callback.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterUpdateCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterUpdateHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered on Update event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTriggerCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Trigger event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTriggerHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered by a Trigger event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterInputCaptureCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the Input Capture event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterInputCaptureHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered by an Input Capture event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCompareMatchCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the Compare Match event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCompareMatchHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_channel_cb_t
fct
)
-
Callback registration for the Half Complete DMA transfer triggered by a Compare Match event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCommutationCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Commutation event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterCommutationHalfCpltCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the DMA Half Complete transfer triggered by a Commutation event. for the timer.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterBreakCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Break event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterBreak2Callback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Break 2 event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterSystemBreakCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the System Break event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterEncoderIndexCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Index event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterDirectionChangeCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Direction Change event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterIndexErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Index Error event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
hal_status_t
HAL_TIM_RegisterTransitionErrorCallback
(
hal_tim_handle_t
*
htim
,
hal_tim_cb_t
fct
)
-
Callback registration for the Encoder Transition Error event.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
fct – Function to register as callback.
-
- Return values :
-
-
HAL_OK –
-
HAL_INVALID_PARAM – fct is NULL (only if USE_HAL_CHECK_PARAM == 1)
-
-
void
HAL_TIM_IRQHandler
(
hal_tim_handle_t
*
htim
)
Timer Setter and Getter of the user data ¶
- group TIM_Exported_Functions_Group18
-
The user data pointer, *p_user_data, in the HAL TIM handle allows user to associate applicative user data to the HAL TIM handle. Thus, the two functions in this group give an application the possibility to store and retrieve user data pointer into and from the handle.
Functions
-
void
HAL_TIM_SetUserData
(
hal_tim_handle_t
*
htim
,
const
void
*
p_user_data
)
¶
-
Store User Data pointer into the handle.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_user_data – Pointer to the user data.
-
-
const
void
*
HAL_TIM_GetUserData
(
const
hal_tim_handle_t
*
htim
)
¶
-
Retrieve User Data pointer from the handle.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
-
(void*) – Pointer to the user data, when previously set by HAL_TIM_SetUserData() .
-
NULL – otherwise.
-
-
void
HAL_TIM_SetUserData
(
hal_tim_handle_t
*
htim
,
const
void
*
p_user_data
)
¶
- group TIM_Exported_Functions_Group18
-
The user data pointer, *p_user_data, in the HAL TIM handle allows user to associate applicative user data to the HAL TIM handle. Thus, the two functions in this group give an application the possibility to store and retrieve user data pointer into and from the handle.
Functions
-
void
HAL_TIM_SetUserData
(
hal_tim_handle_t
*
htim
,
const
void
*
p_user_data
)
-
Store User Data pointer into the handle.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_user_data – Pointer to the user data.
-
-
const
void
*
HAL_TIM_GetUserData
(
const
hal_tim_handle_t
*
htim
)
-
Retrieve User Data pointer from the handle.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
-
(void*) – Pointer to the user data, when previously set by HAL_TIM_SetUserData() .
-
NULL – otherwise.
-
-
void
HAL_TIM_SetUserData
(
hal_tim_handle_t
*
htim
,
const
void
*
p_user_data
)
- group TIM_Exported_Functions_Group18
-
The user data pointer, *p_user_data, in the HAL TIM handle allows user to associate applicative user data to the HAL TIM handle. Thus, the two functions in this group give an application the possibility to store and retrieve user data pointer into and from the handle.
Functions
-
void
HAL_TIM_SetUserData
(
hal_tim_handle_t
*
htim
,
const
void
*
p_user_data
)
-
Store User Data pointer into the handle.
- Parameters :
-
-
htim – Pointer to the handle of the TIM instance.
-
p_user_data – Pointer to the user data.
-
-
const
void
*
HAL_TIM_GetUserData
(
const
hal_tim_handle_t
*
htim
)
-
Retrieve User Data pointer from the handle.
- Parameters :
-
htim – Pointer to the handle of the TIM instance.
- Return values :
-
-
(void*) – Pointer to the user data, when previously set by HAL_TIM_SetUserData() .
-
NULL – otherwise.
-
-
void
HAL_TIM_SetUserData
(
hal_tim_handle_t
*
htim
,
const
void
*
p_user_data
)