2 Replies Latest reply on Oct 8, 2018 10:21 PM by user_13463998

    PWM line output set to constant low

    dimasidi

      hi,

       

      I need to set the line output of the PWM to constant low through the code.

      And then start PWM back again when necessary.

       

      image:

       

      how can i do so?

        • 1. Re: PWM line output set to constant low
          bob.marlowe

          Just set the compare value to zero (0). Then the line output will drop to logical "Low".

           

          Bob

          1 of 1 people found this helpful
          • 2. Re: PWM line output set to constant low
            user_13463998

            Hi,

             

            Although Bob-san has already provided correct answer,

            let me add some supererogatory comment ;-)

             

            In your case writing compare value to zero(0) means calling

            PWM_BUZZ_WriteCompare(0) ;

             

            So I hacked something like,

            ======================

            #include "project.h"

             

            void BUZZ_On(void)

            {

                PWM_BUZZ_WriteCompare(32767) ; /* duty 50% for 65535 */

            }

             

            void BUZZ_Off(void)

            {

                PWM_BUZZ_WriteCompare(0) ; /* line is constant 0 */

            }

             

            int main(void)

            {

                CyGlobalIntEnable; /* Enable global interrupts. */

             

                PWM_BUZZ_Start() ;

             

                for(;;)

                {

                    BUZZ_On() ;

                    CyDelay(1000) ;

                    BUZZ_Off() ;

                    CyDelay(1000) ;

                }

            }

            ======================

             

            Being an old guy, I can not hear 5MHz sound,

            so I connected the BUZZER pin to LED_GREEN

            and when LED_GREEN is full bright, the PWM value is logically 0,

            and when LED_GREEN is half bright, the PWM value is 32767 which

            makes the duty 50%.

             

            Attached is my trial with CY8CKIT-044.

             

            moto

            1 of 1 people found this helpful