cancel
Showing results for 
Search instead for 
Did you mean: 

PWM No Output for TIM1 on STM32L476

PeterL
Associate III

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...)

 

1 ACCEPTED SOLUTION

Accepted Solutions

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?!?

View solution in original post

7 REPLIES 7

I don't use Cube but TIM1 is an Advanced Timer and needs TIMx_BDTR.MOE to be set.

JW

Sarra.S
ST Employee

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.

PeterL
Associate III

Just to verify that PE14 is operational i once more (typo PE15 in original post) verified my setup for measurement, and it seems fine.

As far as I understand the MOE is set with the PWM project.

PeterL_0-1711030182524.png

 

Show all Timer and relevant GPIO registers content.

JW

AScha.3
Chief III

@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:

 

If you feel a post has answered your question, please click "Accept as Solution".

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?!?

So set period (arr) to 9 , not 20.   (80 / (9+1) = 8 MHz )

If you feel a post has answered your question, please click "Accept as Solution".