cancel
Showing results for 
Search instead for 
Did you mean: 

How to get fixed number of pulses with PWM mode on STM32f205xx

Skada.3
Associate III

Using timer 1 for PWM cycle generationand getting proper PWM pulses using Standarad peripheral library.

My requirement is to get fixed number of PWM pulses on each channel of Timer 1

For this I have used one pulse mode. using HAL library able to get desired output but with standarad peripheral library not able to get pulses.

I have attached source file for code.

Please suggest what step is missing in the code.

1 ACCEPTED SOLUTION

Accepted Solutions
Skada.3
Associate III

Hi

got an expected output with the same main.c file.

Thanks

View solution in original post

8 REPLIES 8

Read out and check/compare content of TIM1 and relevant GPIO registers.

TIM1 is Advanced Timer, so it needs to have TIM1_BDTR.MOE set.

JW

Skada.3
Associate III

Hi jan,

Thank you for your response.

In code TIM1_BDTR.MOE is already set using TIM_CtrlPWMOutputs(TIM1, ENABLE)

without enabling I will not get PWM cycle, I am facing issue to get fixed number of pulses on channel.

> I am facing issue to get fixed number of pulses on channel.

What does this mean? Do you see less or more pulses than you expect?

You are supposed to set TIMx_BDTR.MOE *before* you enable the counter.

Read out and check/post content of TIM1 registers.

JW

Skada.3
Associate III

After PWM enable then it gives continous output. but for example I required only 100 pulses on channel 1, this fixed output I am not able to get.

This is possible using RCR register and getting output using HAL library but with standarad peripheral it fails.

Read out and check/post content of TIM1 registers.

JW

Skada.3
Associate III

Hi JW,

Didn't get your suggestion.

In debugger, stop execution just before enabling the timer, and read out the TIM1 registers.

If you don't use debugger, then transmit/print/output in whatever method the content of TIM1 registers.

JW

Skada.3
Associate III

Hi

got an expected output with the same main.c file.

Thanks