PWM delay needed after waking up?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
user_1669321
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Hi,

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,

Fred

1 Solution

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.

GS003336.png

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.

Regards,

Noriaki

View solution in original post

9 Replies
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

I assumed that your schematic is as follows.

GS003334.png

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?

Regards,

Noriaki

0 Likes

Hi,

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

PWM_Wakeup();

CR1_Wakeup();

CyDelayUs(30);

CR1_Write(1);

// Do something, now ready to sleep

CR1_Sleep();

PWM_Sleep();

CySysPmDeepSleep();

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,

Fred

0 Likes

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.

GS003336.png

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.

Regards,

Noriaki

Anonymous
Not applicable

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.

0 Likes

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.

Thanks,

Fred

0 Likes
Anonymous
Not applicable

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

0 Likes

Not yet, I'll do it on Monday.

0 Likes

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?

Fred

0 Likes
Anonymous
Not applicable

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)

0 Likes