High frequency PWM

chiricocuvie
Posts: 2
Joined: Fri Feb 10, 2023 8:23 am

High frequency PWM

Postby chiricocuvie » Fri Feb 10, 2023 2:44 pm

Hello guys ,
I am trying to generate 10Mhz PWM signal using the LEDC.
Unfortunately whenever the frequency is above 8 Mhz , i don't get a consistent signal at all (the frequency fluctuates & same for Duty cycle)
Here is a sample for 12Mhz 50% duty cycle
Image

Code is pretty straightforward :https://pastebin.com/VMr19BGm

What could be the issue and ty for your help in advance.

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: High frequency PWM

Postby ESP_Sprite » Sat Feb 11, 2023 3:10 am

It's because the LEDC is configured to use the APB clock which is 80MHz, and that doesn't divide cleanly into 12MHz (80/12=6.66, and iirc that number has to be a multiple of 2 to 'fit'). In order to get the frequency as close as possible, the LEDC uses dithering, meaning it'll introduce longer and shorter pulses to generally get the frequency as close as possible to 12MHz.

chiricocuvie
Posts: 2
Joined: Fri Feb 10, 2023 8:23 am

Re: High frequency PWM

Postby chiricocuvie » Sat Feb 11, 2023 9:48 am

Thanks for the reply.
I tried with 10Mhz still the same problem.
I think the problem comes from my logic analyzer, I m using one of those cheap salae clones from Aliexpress .
They don"t support high frequencies and anything north of 8Mhz it produces junk.

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: High frequency PWM

Postby ESP_Sprite » Sun Feb 12, 2023 1:45 am

Those things top out at 24MHz sample rate, so they'll only be able to measure *something* up to a frequency of 12MHz, and they will be able to properly tell you the shape of the waveform only up to a few MHz at best, so yeah, sounds like that might be your issue.

Who is online

Users browsing this forum: No registered users and 72 guests