cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with interrupt time to compare

OADDI.1
Associate II

Hello

I have some problems with an interruption on the STM32H7. I'm working on a project and i implemented a timer with two interrupts (OVF and CC1) and that worked.

But after trying to implement HSEM that no working even with an old version.

That's the code of the init of timer2 and the IRQ

 void TIM2_Init(void)
{
	RCC->APB1LENR |= RCC_APB1LENR_TIM2EN;
	TIM2 -> CR1 = 0; //Auto-reload preload enable // upcounter
	TIM2 -> PSC = 120; //Prescaler // F=2MHz
	TIM2 -> ARR = VALUE_TIMER; //0.5us per echantillon => 20ms for 40000
	TIM2 -> CCMR1 |= 0x18; //OC1M Channel 1 active | OC preload enable
	/* USER CODE BEGIN TIM2_Init 2 */
	TIM2 -> DIER |= 0x01; //activer interrupt OVF et CC1
	TIM2 -> CR1 |= TIM_CR1_CEN;  // upcounter
  /* USER CODE END TIM2_Init 2 */
 
}
 
 void enable_interrupt_CC1(void)
{
		TIM2 -> DIER |= 0x02; //activer interrupt OVF et CC1
}
 void TIM2_IRQHandler(void)
 {
 	// Si le flag est pour OVF
 	if((TIM2 -> SR) & 0x0001)
     {
 		tick1 = HAL_GetTick();
 	    timer_value = tick1-tick2;
 	    tick2 =tick1;
 	    seq_it_top20();
     }
 	else if((TIM2 -> SR) & 0x0002) seq_it_inst(); //FLAG pour comparaison
 }

Do you think it's a hardware issue ?

Thanks

0 REPLIES 0