2 Replies Latest reply on Sep 26, 2018 11:50 PM by MoTa_728816

    New to PSOC Creator & PSOC - PWM & IDE Questions

      Hey everyone,


      New to PSOC6/Creator but I am an experienced coder.


      - Using PSOC6 explorer board

      - PSOC Creator 4.2

      - Created a new, simple SCH of a GPIO, driven by a PWM. (SEE ATTACHED)

      - LED is active-low on this board (SEE ATTACHED).

      - PWM is driven by a 4MHz clock source, 50% DC. 16-bit, giving me a ~120Hz PWM - Cool



      Been trying to enable/disable the LED to make it blink, but when I called the given LED_Disable() call in LED.c/.h it does not work, the LED is always on.


      - Also tried driving an OE pin using PWM and setting the GPIO to logic-0 in the SCH, which didn't work.


      Does anyone have any idea why I can't enable/disable the PWM?


      In the LED.h there is:


      void LED_PWM_Start(void);

      __STATIC_INLINE cy_en_tcpwm_status_t LED_PWM_Init(cy_stc_tcpwm_pwm_config_t const *config);

      __STATIC_INLINE void LED_PWM_DeInit(void);

      __STATIC_INLINE void LED_PWM_Enable(void);

      __STATIC_INLINE void LED_PWM_Disable(void);


      the enable/disable functions yield no changes.


      That is the first issue.


      The next issue is, when I try to add to the LED.c/.h the file erases when I make a tweak to the SCH &  rebuild, I'll assume I have to make a HAL above these .c and .h 's ?? I was editing the .c and .h because The PWM functions are static, so I drops a quick non-static function so I could control the PWM in main.c. How do you manage this situation? It seems you can't edit the component drivers are they will be updated on rebuild.

        • 1. Re: New to PSOC Creator & PSOC - PWM & IDE Questions

          Please attach your complete program by Clicking on File and then click on Create_WorkSpace_Bundle and attach the zip file to a new comment using the Advanced editor.

          • 2. Re: New to PSOC Creator & PSOC - PWM & IDE Questions



            If your ClkPWM is 1MHz, and the period is 65535 (default),

            the PWM frequency will be 61Hz, which we can hardly see the blink.

            So it appears to be on all the time, not as bright as full on though.


            I tried to change the clk to 1kHz and period to 1000 and compare to be 500.

            So I could see the LED blinking.


            As far as I tried, using LED_PWM_Disable() and LED_PWM_Start()

            seem to be working.


            When I want to add tweak on top of HAL, I'd create a new source and header

            in user space, I mean next to main.c (main_cm0p.c etc), such as

            LED_PWM_usr.h LED_PWM_usr.c and add additional codes in them.


            Attached is my trial, with SW2, LED_PWM can be stopped and started.



            P.S. I may misunderstood your point,

            connecting LED to pwm_n makes LED off when PWM is disabled.