Skip to main content
PeterL
Associate III
March 21, 2024
Solved

PWM No Output for TIM1 on STM32L476

  • March 21, 2024
  • 5 replies
  • 3290 views

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

 

This topic has been closed for replies.
Best answer by PeterL

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

5 replies

waclawek.jan
Super User
March 21, 2024

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

JW

ST Employee
March 21, 2024

Hello @peter_3993,

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
PeterLAuthor
Associate III
March 21, 2024

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

 

waclawek.jan
Super User
March 21, 2024

Show all Timer and relevant GPIO registers content.

JW

AScha.3
Super User
March 21, 2024

@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""."
PeterL
PeterLAuthorBest answer
Associate III
March 21, 2024

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

AScha.3
Super User
March 21, 2024

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