Skip to content

In HardwareTimer library, generic update callback should clear update interrupt flag (UIF) automatically #1400

@AndrewBCN

Description

@AndrewBCN

Hello,
This is a suggestion for a small improvement in the HardwareTimer library, which I have been using.
In the HardwareTimer library, in file https://github.com/stm32duino/Arduino_Core_STM32/blob/master/cores/arduino/HardwareTimer.cpp
specifically in the following function:
/** * @brief Generic Update (rollover) callback which will call user callback * @param htim: HAL timer handle * @retval None */void HardwareTimer::updateCallback(TIM_HandleTypeDef *htim){ if (!htim) { Error_Handler(); } timerObj_t *obj = get_timer_obj(htim); HardwareTimer *HT = (HardwareTimer *)(obj->__this); if (HT->callbacks[0]) { HT->callbacks[0](); }}

One can see that the Update Interrupt Flag (UIF) for the timer in question is not cleared by the generic update callback function.

My suggestion is that the UIF flag should be cleared and that this should be documented in wiki, that there is no need for the user callback function to manually clear this flag.

The purpose of having the flag cleared automatically by the callback function is that the flag can then be tested by user code to check if the user callback function has executed or not, consequently we know if there was an update event and that it has already been handled by the user callback function.

I have checked the programming manual and the UIF is not cleared by hardware, only by software.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions