2024-03-21 05:00 AM - edited 2024-03-21 06:56 AM
I use Cube to setup TIM1_CH4 on PE14 as PWM
Setup of ioc
PE14 -> TIM1_CH4 in pinout
TIM1:
Ch 4 PWM Generation Ch4
Conter Settings: Counter period 20
PQM Generation Cannel 4: Pulse 5
Modification of main:
/* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4);
It should be this simple, but no output on PE14...
(I tested PE14 as GPIO so its not wrong pin I look at...)
Solved! Go to Solution.
2024-03-21 08:01 AM
I actually got it to work at 4 MHz now, but not 8 MHz as was my goal.
Conter Period should be 9 and pulse should be 5 I guess. That worked for TIM2 but not for TIM1... It is too advanced to be fast?!?
2024-03-21 05:45 AM
I don't use Cube but TIM1 is an Advanced Timer and needs TIMx_BDTR.MOE to be set.
JW
2024-03-21 06:20 AM
Hello @peter,
This should work with HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4); your config/ code looks correct
I see you're using a custom board, have you tried to output another signal on those pins?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-03-21 07:10 AM
2024-03-21 07:16 AM
Show all Timer and relevant GPIO registers content.
JW
2024-03-21 07:34 AM
@PeterL , you set timer to 80/20 -> 4MHz output, with 5 ticks pwm, 60ns pulse.
But set pin to low speed, -> set high.
And set debug not to disable, if you want to debug.
try mod. ioc:
2024-03-21 08:01 AM
I actually got it to work at 4 MHz now, but not 8 MHz as was my goal.
Conter Period should be 9 and pulse should be 5 I guess. That worked for TIM2 but not for TIM1... It is too advanced to be fast?!?
2024-03-21 08:18 AM - edited 2024-03-21 08:23 AM
So set period (arr) to 9 , not 20. (80 / (9+1) = 8 MHz )