HAL_HRTIM_WaveformCounterStop_IT delay due to "delai"
Hi. Im using HRTIM and HAL in my project.
To stop Master timer with subsequent interrupt call I use HAL_HRTIM_WaveformCounterStop_IT (it is defined in stm32_hal_legacy.h) and it calls HAL_HRTIM_WaveformCountStop_IT from stm32g4xx_hal_hrtim.c.
Pic.1 shows how long it takes to process this function call, and it is enormous 27.94us.
Yes, I know HAL is kinda slow and for maximum efficiency one should use direct registers call.
I suggest the culprit is delay inserted in this function (variable called "delai").
HAL_StatusTypeDef HAL_HRTIM_WaveformCountStop_IT(HRTIM_HandleTypeDef *hhrtim,
uint32_t Timers)
{
/* ++ WA */
__IO uint32_t delai = (uint32_t)(0x17FU);
/* -- WA */
uint8_t timer_idx;
/* Check the parameters */
assert_param(IS_HRTIM_TIMERID(Timers));
/* Process Locked */
__HAL_LOCK(hhrtim);
hhrtim->State = HAL_HRTIM_STATE_BUSY;
/* Disable HRTIM interrupts (if required) */
__HAL_HRTIM_DISABLE_IT(hhrtim, hhrtim->Init.HRTIMInterruptRequests);
/* Disable master timer related interrupts (if required) */
if ((Timers & HRTIM_TIMERID_MASTER) != 0U)
{
/* Interrupts enable flag must be cleared one by one */
__HAL_HRTIM_MASTER_DISABLE_IT(hhrtim, hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].InterruptRequests);
}
/* Disable timing unit related interrupts (if required) */
for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
timer_idx < HRTIM_TIMERINDEX_MASTER ;
timer_idx++)
{
if ((Timers & TimerIdxToTimerId[timer_idx]) != 0U)
{
__HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, timer_idx, hhrtim->TimerParam[timer_idx].InterruptRequests);
}
}
/* ++ WA */
do { delai--; } while (delai != 0U);
/* -- WA */
/* Disable timer(s) counter */
hhrtim->Instance->sMasterRegs.MCR &= ~(Timers);
hhrtim->State = HAL_HRTIM_STATE_READY;
/* Process Unlocked */
__HAL_UNLOCK(hhrtim);
return HAL_OK;
}
When I commented line 40
/* ++ WA */
// do { delai--; } while (delai != 0U);
/* -- WA */
Pic.1 HAL_HRTIM_WaveformCountStop_IT call execution time.
Pic.2 HAL_HRTIM_WaveformCountStop_IT call execution time with commented delai cycle..