2022-07-12 03:08 AM
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.
Solved! Go to Solution.
2022-07-12 09:44 PM
2022-07-12 03:34 AM
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
2022-07-12 03:42 AM
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.
2022-07-12 03:51 AM
> 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
2022-07-12 03:54 AM
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.
2022-07-12 04:38 AM
Read out and check/post content of TIM1 registers.
JW
2022-07-12 04:54 AM
Hi JW,
Didn't get your suggestion.
2022-07-12 05:28 AM
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
2022-07-12 09:44 PM
Hi
got an expected output with the same main.c file.
Thanks