9 Replies Latest reply on Oct 29, 2017 2:42 PM by user_1669321

    PWM delay needed after waking up?




      I'm using the CYBLE-014008-00 and I've had some problems using a PWM module (UDB). I want to use the PWM as a single shot triggered by a Control Register module (i.e. triggered by firmware), and the clock used is LFCLK at 32.768 kHz.


      Everything was working fine in active mode and sleep mode, unless I used the functions PWM_Sleep() and PWM_Wakeup(). Then the PWM stopped working.


      I tried adding a 30us delay after PWM_Wakeup() and then it works! I can go to sleep and deepsleep with my system without problems.


      My question is: is this normal? Do the UDB modules (specifically the PWM) require a delay after waking up? If so, where can I see the specs? By trial and error, I found that I need ~6 microseconds delay after waking up from sleep, and ~40 microseconds after waking up from deep sleep.


      Thank you,



        • 1. Re: PWM delay needed after waking up?

          I assumed that your schematic is as follows.




          Please let me ask some questions.


          1) What is the output mode of the Control Register?  If Pulse mode is used, what is provided to the clock input?

          2) Control Register component has _Sleep/_Wakeup methods.  Did you use these APIs?  If you used, what is the calling order of these APIs?




          • 2. Re: PWM delay needed after waking up?



            You're right for the schematic, except the PWM is in 16 bits with only one output, and the reset input is forced at zero.


            The Control Reg mode is Sync mode, and the clock is HFCLK/2. The reset input is the TC output of the PWM.


            The order is as follows:


            // Wake up with WDT






            // Do something, now ready to sleep





            I didn't think about it, but it's right that the Control Reg could be the culprit. However, when I was testing with only Sleep (not deep sleep), I used the API Sleep and Wakeup functions of the Control Reg, and the system worked well.


            Thank you for your time,



            • 3. Re: PWM delay needed after waking up?

              Thank you for clarification.  It seems that the PWM component does not accept a trigger until the first clock edge is provided.  If the problem is that the Control Register component is faster than the PWM component, please try to use same clock for the Control Register and the PWM components.  Following figure is my solution.  But I didn't try if the schematic works well because I have no hardware right now.


              The LFCLK is synchronized with the 24MHz (HFCLK/2) clock and drives both components.  The Control Register is configured as the Pulse mode to generate a one-shot pulse.




              1 of 1 people found this helpful
              • 4. Re: PWM delay needed after waking up?

                I believe the sleep/deep sleep modes also turn off the clocks to save power (depending on your firmware/code). Potentially, the clocks aren't quite ready for use/stable?

                I'm probably wrong with this, but I figured it was something worth thinking about.

                • 5. Re: PWM delay needed after waking up?

                  Thanks for the answer,


                  That definitely is possible, I will try that next week! But won't it result in the same result as just adding a delay in firmware, just more precise?


                  Also, does adding the Sync block consume more current?



                  • 6. Re: PWM delay needed after waking up?

                    The sleep mode doesn't, but deep sleep does turn off the high frequency clocks. However, I didn't have problems with a timer that uses the same clock as the PWM, so I don't think the problem is the clock. Also, I use Clock_Disable() and Clock_Enable() when entering and exiting deep sleep, and I think there's code in those functions that ensures that the clock is stable.





                    • 7. Re: PWM delay needed after waking up?

                      Yeah, waiting for the clock to stabilize would be the same thing as a delay in firmware. If the timing varies, then you would  need to make a longer delay that isn't always necessary, but that depends on if and how much the timing varies

                      The Sync block might consume some power, but I would think it would be very small; A single AND gate at the transistor level would achieve the sync effect and would only use miniscule amounts of power.

                      (The documentation for the sync module should give you more direct information on the power consumption and specifications; Right-click on the module and select the open datasheets selection)

                      • 8. Re: PWM delay needed after waking up?

                        Have you tried putting the same clock for both the PWM and the Control_Reg as Noriaki suggested?

                        • 9. Re: PWM delay needed after waking up?

                          Not yet, I'll do it on Monday.