cancel
Showing results for 
Search instead for 
Did you mean: 

The HAL_TIM_PeriodElapsedHalfCpltCallback function doesn't generate an interrupt.

ComandanteChi
Associate

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

8 REPLIES 8
TDK
Guru

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

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

LVara.1
Associate II

"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 .... :- (

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

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

LVara.1
Associate II

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 ....

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 II

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.