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.

LAUNCHXL-F28027F: How to control (start and stop) a PWM signal using Gui Composer

Part Number: LAUNCHXL-F28027F

Hello,

I have programmed 2 PWM signals in CCS and everything is going well in standalone mode,

See below an extract of my main program

     void main(void)
     {
        initSystem();

        CLK_enablePwmClock(myClk, PWM_Number_1); // Enable la clock du PWM1
        CLK_enablePwmClock(myClk, PWM_Number_2); // Enable la clock du PWM2

        initEPWM(myPWM1);
        initEPWM(myPWM2);

     } // END of MAIN

NOW, I want to control the start&stop of the PWM signals through a toggle-button in IHM ==> I build-up a Gui Composer interface, using the variable "GO" for binding the toggle-button and the program.

Herafter is an extract of my main-program for doing that, but it does not work.

   for(;;)
   {
       Start=*(&GO);

       if (*(&Start)!=0)
       {
            Visu_GO=1;
   
            CLK_enablePwmClock(myClk, PWM_Number_1);
            CLK_enablePwmClock(myClk, PWM_Number_2);
            initEPWM(myPWM1);
            initEPWM(myPWM2);
       }

       else
       {
           Visu_GO=0;
           CLK_disablePwmClock(myClk, PWM_Number_1);
            CLK_disablePwmClock(myClk, PWM_Number_2);
       }
   }

Does anyone have an example of this kind of basic application ?

Many thanks in advance for your kind support.

  • Hello Bruno,
    How did you bind the GO variable to the toggle button? Did you bind it to the checked property of the toggle button widget? GO must be a global variable in your target program.

    If you are using CCS to develop your code, try running your program in CCS and update the GO variable while the target is running. Make sure this work before using your target program in GUI Composer.

    Regards,
    Patrick

  • Hello Patrick,

    Thanks for you feedback,

    My "GO" variable is well binded between the toggle button and the software variable ; I could check this because I activate a "Gui LED" in the same time.

    It is not a matter of binding.

    My problem rather comes from an incompatibility between the infinite loop (for(;;) and the independant working of the PWM outputs.

    Regards.

    Bruno

  • Hi Bruno,

    I understand that the PWM signals are to be generated when the toggle switch is pressed once and signals are to be stopped when the switch is pressed another time.

    I will suggest to bring in a another variable which stores the previous state of the PWM. Everytime the toggle switch is pressed, read the previous state, decide whether you need to enable the PWM or disable it and update the state. This will ensure that enable PWM works only when the previous state is disabled and vice versa.

    Also, you need not initialize the PWM every time you need to generate the PWM signals so the initialization PWM part can remain outside the infinite loop unless you are resetting each initialized bits in the disablePWMClock().

    One question from my end: What brings in the need to write Start = *(&GO) and *(&Start) rather than using directly --> Start = GO?

    Thanks,

    Aditya

  • Hello Aditya,

    Thank you very much for your kind reply and advice. And sorry for my late feedback (I was busy on other subjects).

    I tried what you said and, indeed, it was a question of asking for the right variable at the right time. Now it works.

    Concerning your question; there was no reason, it was just one attempt among many other attempts.

    Thanks again.

  • Hi Bruno,

    Glad that this resolved. Thanks for your reply.

    Regards,

    Aditya