HAL LPTIM How to Use

group LPTIM_How_To_Use

The LPTIM HAL driver can be used as follows

(Non optional call) Call HAL_LPTIM_Init(), to initialize the LPTIM driver by establishing a link with

the LPTIM physical instance.

(Non optional call) Call HAL_LPTIM_SetConfig(), to Configure the timebase unit :

If needed, HAL_LPTIM_DeInit() can be called to reset the driver.

When an external clock is used, configure the LPTIM input1 by calling the HAL_LPTIM_SetConfigInput1()

select your usage :

- To use LPTIM instance as a simple counter:

- To generate a PWM signal:

- To generate a One pulse signal:

- To generate a set once signal:

- To capture an input signal:

- To use the LPTIM timeout feature:

- To use the LPTIM encoder interface:

Callbacks definition in Interrupt or DMA mode

  • When the compilation define USE_HAL_LPTIM_REGISTER_CALLBACKS is set to 1, the user can configure dynamically the driver callbacks, via its own method:

Callback name

Default callback

Register callback

ErrorCallback

HAL_LPTIM_ErrorCallback

HAL_LPTIM_RegisterErrorCallback

StopCallback

HAL_LPTIM_StopCallback

HAL_LPTIM_RegisterStopCallback

InputCaptureStopCallback

HAL_LPTIM_InputCaptureStopCallback

HAL_LPTIM_RegisterChannelStopCallback

UpdateCallback

HAL_LPTIM_UpdateCallback

HAL_LPTIM_RegisterUpdateCallback

UpdateHalfCpltCallback

HAL_LPTIM_UpdateHalfCpltCallback

HAL_LPTIM_RegisterUpdateHalfCpltCallback

RepUpdateCallback

HAL_LPTIM_RepUpdateCallback

HAL_LPTIM_RegisterRepUpdateCallback

TriggerCallback

HAL_LPTIM_TriggerCallback

HAL_LPTIM_RegisterTriggerCallback

InputCaptureCallback

HAL_LPTIM_InputCaptureCallback

HAL_LPTIM_RegisterInputCaptureCallback

InputCaptureHalfCpltCallback

HAL_LPTIM_InputCaptureHalfCpltCallback

HAL_LPTIM_RegisterInputCaptureHalfCpltCallback

InputOverCaptureCallback

HAL_LPTIM_InputOverCaptureCallback

HAL_LPTIM_RegisterOverCaptureCallback

CompareMatchCallback

HAL_LPTIM_CompareMatchCallback

HAL_LPTIM_RegisterCompareMatchCallback

CompareUpdateCallback

HAL_LPTIM_CompareUpdateCallback

HAL_LPTIM_RegisterCompareUpdateCallback

AutoReloadMatchCallback

HAL_LPTIM_AutoReloadMatchCallback

HAL_LPTIM_RegisterAutoReloadMatchCallback

AutoReloadUpdateCallback

HAL_LPTIM_AutoReloadUpdateCallback

HAL_LPTIM_RegisterAutoReloadUpdateCallback

DirectionDownCallback

HAL_LPTIM_DirectionDownCallback

HAL_LPTIM_RegisterDirectionDownCallback

DirectionUpCallback

HAL_LPTIM_DirectionUpCallback

HAL_LPTIM_RegisterDirectionUpCallback

If one needs to unregister a callback, register the default callback via the registration function.

By default, after the HAL_LPTIM_Init() and when the state is HAL_LPTIM_STATE_INIT , all callbacks are set to the corresponding default weak functions.

Callbacks can be registered in handle global_state HAL_LPTIM_STATE_INIT and HAL_LPTIM_STATE_IDLE .

When the compilation define USE_HAL_LPTIM_REGISTER_CALLBACKS is set to 0 or not defined, the callback registration feature is not available and weak callbacks are used, represented by the default value in the table above.

Note

If needed, some configurations parameters can be changed on the fly (e.g: Period HAL_LPTIM_SetPeriod() ).

Note

If needed, some configurations parameters can be changed on the fly (e.g: PWM duty cycle HAL_LPTIM_OC_SetChannelPulse() ).

Note

In case of software start (external trigger not configured), call HAL_LPTIM_Start()

to starts the LPTIM counter for one-shot counting.

In one pulse mode the output waveform is similar to the one of the PWM mode for the first pulse, then the output is permanently reset.

Note

if needed, some configurations parameters can be changed on the fly (e.g: PWM duty cycle HAL_LPTIM_OC_SetChannelPulse() ).

Note

if needed, some configurations parameters can be changed on the fly (e.g: PWM duty cycle HAL_LPTIM_OC_SetChannelPulse() ).

Note

if needed, some configurations parameters can be changed on the fly (e.g: Period HAL_LPTIM_SetPeriod() ).