1 Reply Latest reply on Apr 27, 2018 9:39 AM by e.pratt_1639216

    Creating PWM on Interrupt from Zero Cross Detector

    ameya_mahajan_2724956

      Hello,

       

      I want to write PWM when we get Interrupt, which is connected to ZCD.

       

      Please provide any method for doing this.

       

      Thanks in Advance.

        • 1. Re: Creating PWM on Interrupt from Zero Cross Detector
          e.pratt_1639216

          Upon interrupt, set a flag.

          Check the flag in main, and when it gets set, clear it, then turn on the PWM with PWM_Start().

          If you want to change the PWM settings, then you will want to call PWM_Init() with the settings when you want to change them.

          The API will change based on which PWM implementation you used, but something similar to the following should work:

           

          At startup:

               TCPWM_Init();

          In ISR:

               PWM_Start_Flag = true;

          In Main:

               if(PWM_Start_Flag) {

                    PWM_Start_Flag = false;

                    if(TCPWM_ReadStatus() != STATUS_RUNNING) {

                         TCPWM_Start();

                    }

               }