2023-10-25 06:59 PM
2023-10-26 12:59 AM - edited 2023-10-26 01:01 AM
What's exactly happening? "The chip crashes" is rather vague... Debugged?
Did you check:
- the reference manual, any prereqs for changing a CCR register on the fly?
- the macro __HAL_TIM_SET_COMPARE ?
- try without the macro, some direct register setting, should be something like "TIM3->CCR1 = 1800;"
- sure that ARR (?) > 1800 ?
The timers are not too hard to handle via direct register settings, maybe check that instead of HAL / MX stuff.
2023-11-01 01:53 AM
I guess It is because to update the TIM3 configuration too quickly, you can try to control the duration of this setting or add one flag here and move "__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_1, 1800);" to main(), like below: