Skip to main content
Hamid1
Associate
February 19, 2021
Solved

Hi I need to generate a one pulse mode, but I need to trigger PWM inside software by writing code not by trigger a pin in CPU.. How could I do it ? which register should be 1 ?

  • February 19, 2021
  • 6 replies
  • 1561 views

I mean, I setup TIM1 CH1 as output PWM, One pulse mode, but I need to trigger it by my codes

for example which register should be set to high or low to generate a pulse on TIM1 CH1

    This topic has been closed for replies.
    Best answer by waclawek.jan

    You don't need any "trigger source" if you want to start the timer by software.

    "Trigger" there means an input which, through hardware and the slave-mode controller (see TIMx_SMCR) enables the same TIMx_CR1.CEN bit.

    https://community.st.com/s/question/0D53W00000ZWPHkSAP/generate-single-pulse-using-timer-using-hal-cubemx is a post of somebody who had a similar problem recently.

    JW

    6 replies

    waclawek.jan
    Super User
    February 19, 2021

    TIM1->CR1 |= TIM_CR1_CEN;

    JW

    Hamid1
    Hamid1Author
    Associate
    February 19, 2021

    Thanks Waclawek.. so that, which is trigger source ? which trigger source I should select in config ?

    Hamid1
    Hamid1Author
    Associate
    February 19, 2021

    is it right ?

    Trigger source : ITR0

    waclawek.jan
    waclawek.janBest answer
    Super User
    February 19, 2021

    You don't need any "trigger source" if you want to start the timer by software.

    "Trigger" there means an input which, through hardware and the slave-mode controller (see TIMx_SMCR) enables the same TIMx_CR1.CEN bit.

    https://community.st.com/s/question/0D53W00000ZWPHkSAP/generate-single-pulse-using-timer-using-hal-cubemx is a post of somebody who had a similar problem recently.

    JW

    Hamid1
    Hamid1Author
    Associate
    February 19, 2021

    Thanks, I will try it and hope to reach it:grinning_face: