Skip to main content
ComandanteChi
Associate
February 2, 2022
Question

The HAL_TIM_PeriodElapsedHalfCpltCallback function doesn't generate an interrupt.

  • February 2, 2022
  • 8 replies
  • 5558 views

That's how it looks:

  • Started the TIM4 interrupt mode:
/* USER CODE BEGIN 2 */
 HAL_TIM_Base_Start_IT(&htim4);
 /* USER CODE END 2 */
  • The counter values should be incremented in the middle and in the end of the period, however it doesn't happen. There is a problem with the HAL_TIM_PeriodElapsedHalfCpltCallback function. The half_elapsed variable is not inctemented during debugging.
/* USER CODE BEGIN 4 */
 
void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim)
{
	half_elapsed++;
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
	elapsed++;
}
 
/* USER CODE END 4 */
  • These are my Cube settings:

0693W00000JOGqMQAX.png0693W00000JOGoVQAX.png

This topic has been closed for replies.

8 replies

TDK
February 2, 2022

HAL_TIM_PeriodElapsedHalfCpltCallback is not called in most scenarios, including this one. It's used during certain DMA transfers and is called when the DMA's HT interrupt kicks off.

Despite the name, and despite the poor documentation of this function, there is no timer interrupt option for half of the period elapsed.

"If you feel a post has answered your question, please click ""Accept as Solution""."
ComandanteChi
Associate
February 3, 2022

Thank you very much, TDK. :smiling_face_with_smiling_eyes: I will find another sotution then.

LVara.1
Associate III
November 26, 2022

"HAL_TIM_PeriodElapsedHalfCpltCallback is not called in most scenarios, including this one. It's used during certain DMA transfers and is called when the DMA's HT interrupt kicks off."

"Certain DMA" ... but in DMA2 I use I have no call at HalfCplt .... :- (

waclawek.jan
Super User
November 26, 2022

Start a new thread, stating what's your hardware and software, what are the expectations and how are the symptoms different from them.

Read out and check TIM and relevant DMA registers content. If you see the respective DMA status bit being set but still no interrupt, some generic "interrupt does not fire" troubleshooting hints here.

JW

S.Ma
Principal
November 26, 2022

Which STM32 are we talking about? Not all STM32 are the same rspective to DMA

LVara.1
Associate III
November 27, 2022

I was tryng a simple example on a Ncucleo STM32F401RE: read and convert on ADC1 internal temperature sensor and VCal (for calibration), cotrolling the start conversion via TIM3 (each 1000 mSec) and tranferring data on a buffer via DMA2. At half time I need toggle a led (is more clear) . But ....

Piranha
Principal III
November 29, 2022

The previously mentioned callback is for half of the DMA items. If you need half of the timer period, just use an output compare channel to toggle a pin and/or get an interrupt.

LVara.1
Associate III
November 29, 2022

Many thanks. I'd changed the structure and resolved the problem. I use the timer at a higer Tim3 pulse frequency (100 times higer) and I set DMA to complete the transfers on 100 lectures.

In this way i can control the pulse number ( olso in this way there is no half time call from DMA).

Many thanks.