Stm32 pwm generation in freertos

Hi ,
I’m trying to do pwm application for buzzer in freertos.
When I try to use TIM1 module CH2 for pwm generation i get errors. in my thread.
So I can not use HAL_TIM modules, macros .Anyone to help me pleas ?

Hello @Furki81
Using TIM1 and FreeRTOS shouldn’t be a problem. Except if you’ve also configured TIM1 as FreeRTOS SysTick timer ? That would cause problems, of course.
Otherwise you should add some more details to get useful assistance.
Which MCU type, FreeRTOS version + port, IDE or SDK used (sounds like STM32 HAL based application ?) and maybe the related, problematic code (quoted by enclosing it by 3 tildes ‘~’ or backticks ‘`’ or using the </> button.

I’m using Stm32WB mcu. (Freertos cmsis V2) I use TIM17 as Timebase Systick. (not TIM1.)
And using Stm32cube IDE . I’m trying to implement TIM1_CH2 PWM output to drive a buzzer . I did TIM1 Configurations ın CubeMX… But i failed .

But i noticed that TIM1 and TIM17 ınterrupt priority is same. I dont know why? Is this the source of the problem ? YOu can see in the jpec file.

@Furki81 According to ST RM0434 section 7.4.1, TIM1 and TIM17 are linked together to offer some level of synchronization. There is only a single interrupt vector for TIM17 which is shared with the “TIM1 Trigger and Communication” interrupts.

If using both timers at once, you may need to modify the generated interrupt handler code to determine the source of the interrupt and act accordingly.

It is possible to use SysTick for both Stm32Cube and FreeRTOS at the same time by overriding the HAL_Delay and HAL_InitTick function similar to this file in the stm32u5 FreeRTOS reference integration. You will likely see improved performance due to this change, but you will need to otherwise ensure that only a single task attempts to use a particular peripheral at a time.

Can you give us a better idea of the specific error you are seeing? What works or doesn’t work as expected?