cancel
Showing results for 
Search instead for 
Did you mean: 

Has anyone know what is the difference between HAL_TIM_PWM_Start(),HAL_TIM_PWM_Start_IT() and HAL_TIM_PWM_Start_DMA()?

Poulamee Sur
Associate
Posted on June 27, 2018 at 13:25

Hello,

I am new in timer implementation , I want to generate PWM timer with an external clock using 2 MHz as frequency.. It shall be possible to enable or disable the generation of the PWM signal. I can able to generate, But I have a doubt for running the timer with support should give- blocking , DMA or interrupt ??

I have found three different function is available ,HAL_TIM_PWM_Start(),HAL_TIM_PWM_Start_IT() and HAL_TIM_PWM_Start_DMA() , What is the difference between these three ?? which is suitable for 2Mhz PWM timer generation and why ?

I'm using STM32F7 Nucleo Board

Any help would be appreciated.

Thanks in advance.

4 REPLIES 4
Imen.D
ST Employee
Posted on June 28, 2018 at 12:36

Hello

sur.poulamee@in.bosch.com

Can you please precise if you want to put the 2MHz frequency signal as an input clock source for timer 

or generate PWM timer signal with 2 MHz frequency? If it is possible provide a figure that explain your expected configuration.

If you just want generate a PWM signal, you can use the HAL_TIM_PWM_Start function.

For HAL_TIM_PWM_Start() funtion: 

Starts the PWM signal generation.

The HAL_TIM_PWM_Start_IT() funtion s

tarts the PWM signal with interrupt generation.

 0690X0000060LSTQA2.png

HAL_TIM_PWM_Start_DMA() funtion s

tarts the TIM PWM signal with DMA request generation.

0690X0000060LVgQAM.png

You can refer to the

https://www.st.com/content/ccc/resource/technical/document/application_note/54/0f/67/eb/47/34/45/40/DM00042534.pdf/files/DM00042534.pdf/jcr:content/translations/en.DM00042534.pdf

 it can help you to understand the PWM generation signal.

I recommend you to start from the TIM_PWMOutput example within the

https://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-mcu-packages/stm32cubef7.html

firmware package examples

STM32Cube_FW_F7_V1.11.0\Projects\STM32F746ZG-Nucleo\Examples\TIM\TIM_PWMOutput

With Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
henry.dick
Senior II
Posted on June 28, 2018 at 13:03

'

I want to generate PWM timer with an external clock using 2 MHz as frequency.. '

2Mhz PWM frequency would be nuts, most of the times.

'But I have a doubt for running the timer with support should give- blocking , DMA or interrupt ??'

does HAL come with any documentation? if not, read the code / examples and compare it to datasheet to see how it works.

Poulamee Sur
Associate
Posted on June 28, 2018 at 13:45

Hello

DAHMEN.IMEN

Thank you for your reply , the timer should generate 2 MHz frequency.

If I go with polling method, It will be block the CPU or something else??

Do you have any idea on that ?

Posted on June 28, 2018 at 14:45

Hi 

sur.poulamee

 ,

The CPU cannot be blocked by the timer and to generate the 2MHz frequency, you should apply this equation:0690X0000060LTHQA2.png

Where:

TIM_CLK = timer clock input

PSC = 16-bit prescaler register

ARR = 16/32-bit Autoreload register

I suggest you to use STM32CubeMx tool, which help you to develop your Timer application with easy configuration and generate an initialization code.

WIth Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen