0

Trying to adjust the PWM period value using the macro

__HAL_TIM_SET_COMPARE(&htim4,TIM_CHANNEL_3,299);

but it does not work.

However the macro

__HAL_TIM_SET_AUTORELOAD(&htim4, 599); 

works fine.

why the __HAL_TIM_SET_COMPARE does not work ?.

The board I am using is NUCLEO-F401RE with CUBE-MX generated project on Truestudio.

Filburt
  • 17,626
  • 12
  • 64
  • 115
TonyP
  • 5,655
  • 13
  • 60
  • 94

1 Answers1

2

I had similar issues with this macro, and would opt instead for:

htim4.Instance->CCR3=299; 

Supposing you want to set the capture and compare register of channel three for htim4 to 299 to modify your PWM duty cycle.

kpg987
  • 486
  • 3
  • 11