PWM Output Turning On/Off

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 I am using a 16-bit PWM fed with a 12Mhz clock on a PSoC 5.

   

The PWM is set up in the 'TopDesign' with a period of 1600 counts (approx 133us) and a compare of 100 counts. It is implemented as a UDB block.

   

The only code I have is PWM_Start(), and then PWM_WriteCompare(100), followed by for(;;) to trap the processor.

   

However, the PWM output keeps turning on and off for periods of time that average around 20ms, as shown in the attached picture. When the PWM is on, it is at the right frequency. But then the output will go low (scope is showing the inverted output of the PWM), for between 5-20ms before repeating.

   

I have checked, and the 48MHz oscialltor the PSoC 5 is running off is stable. This problem appears as soon as PWM_Start() is called.

   

All interrupts are disabled 

0 Likes
4 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Any chance you have a floating enable pin tied to the PWM. 20 mS is 50 Hz,

   

also close to 16.66 mS (60 Hz).

   

 

   

The other is an improperly typed code loop, very unexpected stuff can

   

happen if the comipler does not catch it.

   

 

   

Without a project upload diagnosing this will be difficult.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Thanks for your response. The problem is now solved, it happened to be an artifact of the oscilloscopes sampling causing some aliasing! Kinda annoying after 8+ hours of debugging while thinking it was the PSoC's fault. 

   

 

   

It wasn't like I was using a crappy scope (100MHz Rigol), but I borrowed a 1GHz Agilent and proved that the signal was actually fine.

   

 

   

Goes to show you can't always trust what you see 🙂

0 Likes
Anonymous
Not applicable

"you can't always trust what you see"

   

So you trust what you see this time?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I have a 2 Ghz DSO, and a full 1 Ghz analog always at hand for that very reason.

   

 

   

Regards, Dana.

0 Likes