cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 pwm intrupt / hal handler

ahmash
Associate II

hello i m using tim1 to generate pwm and using center alligned mode 1 , timer go to 0 to 1800 then 1800 to zero for one pwm cycle and generate 2 intrrupts 

HAL_TIM_Base_Start_IT(&htim1); //intrrupt i am using

//handler is

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)

{//update happens here

}

while i need one intrrupt for one pwm cycle when timer goes 1800 to zero

what intrrupt and which handler do i need ?please help

 

 

1 REPLY 1

In center-aligned (i.e. up-down) mode, you can't avoid Update being generated at both at top and bottom of the count.

But can use one of the center-aligned modes which generate output compare event only on one of the directions (i.e. TIMx_CR1.CMS=0b01 or 0b10), and use an appropriately set CC channel and its interrupt.

I don't know how to set this in Cube, I don't use Cube/CubeMX.

JW