Skip to main content
Hamid1
Associate
Feb 19, 2021 12:58 PM UTC
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 ?

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.
    waclawek.jan
    waclawek.janBest answer
    Super User
    Feb 19, 2021 1:38 PM UTC

    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
    Feb 19, 2021 1:03 PM UTC

    TIM1->CR1 |= TIM_CR1_CEN;

    JW

    Hamid1
    Hamid1Author
    Associate
    Feb 19, 2021 1:10 PM UTC

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

    Hamid1
    Hamid1Author
    Associate
    Feb 19, 2021 1:24 PM UTC

    is it right ?

    Trigger source : ITR0

    waclawek.jan
    waclawek.janBest answer
    Super User
    Feb 19, 2021 1:38 PM UTC

    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
    Feb 19, 2021 1:41 PM UTC

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