This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to stop PWM generation

Other Parts Discussed in Thread: TM4C1294NCPDT

MC=tm4c1294ncpdt

IDE=keil

In my programme I need to make a particular no of PWM pulses then I have to stop it.For stopping PWM generation I created one Function it is given below

void PWM_Stop(void)
{
        pwm_count = 0;
            PWMPulseWidthSet (PWM0_BASE, PWM_OUT_0, PWMGenPeriodGet(PWM0_BASE, PWM_OUT_0) *0);
            SysCtlDelay ((SysCtlClockGet()/100) );
            PWMGenDisable (PWM0_BASE, PWM_GEN_0);/* Deable the PWM generator block.*/
   
}

The above pgm is a working fine.When ever you need to stop PWM call that function.

According to peripheral library  PWMGenDisable() function is enough to stop PWM generation.But when it is not stopping PWM if I wrote it in the fn alone.So in the above pgm i'm making the pulse width in to zero then providing a delay after that I'm calling PWMGenDisable fn.With out that delay sometimes PWM generation is not stopping.I'm not suppose to use any kind of delays in my project.So please tell me a way to stop PWM generation at any time with out a delay?

  • jithin k joy said:
    ..tell me a way to stop PWM generation at any time with out a delay?

    These "school-like" projects skew further & further from the norm - do they not?    As your client (teacher) enforces, "No Delay" does that restriction extend to, "PWM STOP Sign" too?  (that's about as "real-world" as "No Delay" - is it not?

    In general - ARM MCUs are noted for experiencing difficulty when the PWM is adjusted to (either) extreme.   (meaning full On or full Off.)  It is unclear if your code called, "PWMGenDisable()" without first attempting to drive PWM Width to zero.   Suggest that you try that method - and report.

    If you had called "PWMGenDisable()" while a non: (zero or 100%) duty cycle was underway - my sense is that your program code (likely) Re-Enabled that Generator.

    Two more methods remain:

    • Program the PWM_Fault pin - and then drive it to the appropriate level.   Such will (surely) "kill" your PWM output.
    • As your (teacher) disallows "Delay" - please he/she w/added HW.   Add sufficient resistance between your PWM output and receiving device - and add a GPIO output (config'ed as Open Drain) to "kill the PWM" when that GPIO becomes active.

    First "Go To's" ... and now "Delays" banned - and FOUR YEARS to (maybe) write an APP Note - what's a Programmer-Engineer to do?

  • Thank you cb1 for the above post.I need one more help.I need 2 independent PWM outputs.For that I need to enable PWM modules of different generators(correct me if I am wrong).But only PWM module 0 and PWM module 1 are defined in sysctl.h) which are under same generator(generator 0)

    When I tried to use another PWM module(ie. another generator) compiler is showing warning Bz macro for only PWM0 and PWM1 is defined(in sysctl.h).

    #define SYSCTL_PERIPH_PWM0      0xf0004000  // PWM 0
    #define SYSCTL_PERIPH_PWM1      0xf0004001  // PWM 1

    I cant use other PWM modules bz it is not defined like above in sysctl.h.

    Can you help me with this problem?

  • Sure I can help - but is not your original posting fully & completely answered?   (Ans: indeed it is)

    Yet - there is NO marking, "Verified Answer" - and now you switch to a new subject.

    May I suggest you (properly) fulfill your forum obligation (i.e. Verify my "multiple answers) and then post your new question in a fresh post - properly titled.