3 Replies Latest reply on May 5, 2015 10:59 AM by dakn_263916

    Swap PWM period

    arogc_285336

      I'm trying to do the layout in which the LED will glow with 2 different frequencies.
      I am using  function PWM_SetPeriodSwap () but it has no effect.

      How to turn PWM perio and period_buf?

        • 1. Re: Swap PWM period
          dakn_263916

          You have to check off the swap capability and enter the swap values.

             

           

             

           

             

           

             

           

             

          Note you can do the switch in HW by enabling the switch input and feeding

             

          it with a switch signal.

             

           

             

          Regards, Dana

          • 2. Re: Swap PWM period
            arogc_285336

            I want to use the API and by  software modify the parameters.

               

             

               

                CyGlobalIntEnable;  /* Uncomment this line to enable global interrupts. */
                for(;;)
                {

                    if(counter ==5)
                    {
                        PWM_SetPeriodSwap(1u);
                        PWM_SetCompareSwap(1u);
                    }
                    
                  
                }

               

            Why is this simple code does not work?

            • 3. Re: Swap PWM period
              dakn_263916

              Two questions -

                 

               

                 

              1) Did you check the properties to allow the swap capability ?

                 

               

                 

              2) Can you set a breakpoint and hit it on the swap instruction ?

                 

              Eg. are you getting into the if statement test on counter ?

                 

               

                 

              3) Where do you reset counter variable after doing swap, otherwise

                 

              you will keep repeating the swap commands ?

                 

               

                 

              You also have to have the compare checked.

                 

               

                 

               

                 

               

                 

               

                 

               

                 

              Regards, Dana.