cancel
Showing results for 
Search instead for 
Did you mean: 

Cube generated PWM on TIM17 fails

frackers
Senior
Posted on September 01, 2017 at 01:09

I'm using an stm32f303vc processor and generating code using STM32CUBEMX (4.22.0) to generate PWM1 signals on PB9 using TIM17 channel 1. I'm using HAL version 1.9.0.

All indications are that the output is floating i.e. the output is never enabled.

Is it likely that the generated initialisation code is missing something for this timer?

I'm 'getting round' this issue at present using TIM4 channel 4 but that means I'm loosing a timer elsewhere.

3 REPLIES 3
Posted on September 01, 2017 at 10:38

Don't forget that in TIM17 you need to set TIMx_BDTR.MOE (I don't use Cube so don't know its incantation for that).

If still no go, post content of TIM17 and relevant GPIO registers.

JW

Posted on September 05, 2017 at 02:20

I eventually worked out that BDTR had to be set but I had a devil of a job finding out what to set it to.

What HAL_TIMEx_ConfigBreakDeadTime() does is pretty obscure and that is the only function I could find that manipulated the BDTR register. It would be useful if HAL_TIM_PWM_Start() actually did just that - started the PWM output or if the HAL_TIMEx_ConfigBreakDeadTime() defined the minimum requirement to enable the I/O pin output.

Posted on September 05, 2017 at 08:56

This is a well-deserved punishment for using Cube or any other badly documented 'library'.

I told you what to do. It is a no-brain single liner if you don't want to pretend using any sophistication hidden in unnecessary layers of unneeded code:

TIM17->BDTR = TIM_BDTR_MOE;

I know this sounded harsh, and apologize for that tone, but what I increasingly see on this forum is that many users stick to Cube just to their frustration and struggle with this poor to no documentation and unnecessary complexity with little added benefit, simply because ST pushes this aggressively on all fronts while avoiding normal examples and accompanying concise appnotes.

Thanks for coming back with the solution.

JW

PS. A quick search into CubeF4 (I don't use 'F3 and don't intend to download another gigabyte of fluff) yielded __HAL_TIM_MOE_ENABLE() which I believe does what you needed.