Skip to main content
Poulamee Sur
Associate
June 27, 2018
Question

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

  • June 27, 2018
  • 4 replies
  • 4020 views
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.

    This topic has been closed for replies.

    4 replies

    ST Technical Moderator
    June 28, 2018
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    henry.dick
    Associate II
    June 28, 2018
    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
    June 28, 2018
    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 ?

    ST Technical Moderator
    June 28, 2018
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks