Arduino: Maximum frequency PWM

Created on 21 Dec 2015  路  6Comments  路  Source: esp8266/Arduino

Hi

What is the maximum frequency of the PWM ESP8266 ?

Thanks

Most helpful comment

Here they made it clear, check "Analog output" section. It's 40 KHz the maximum.

All 6 comments

theoretical max frequency is 80000000/range, or for default 1024 range that is 78.125KHz in reality, depending on the number channels and the values that are given, the resolution and timing at that speed might be slightly off.
I'll make a pull request with some optimizations :) looking at the code, there are some that can be done.

Thanks @me-no-dev, I'll try a 1Mhz

So, can I reach (32.768Khz) for master clock in PWM ??

Thanks.

Care to add some references to this? Technical docs note

the function of PWM is realized by interruption of the
timer, the minimum resolution reaches as much as 44 ns. PWM frequency range is
adjustable from 1000 渭s to 10000 渭s, i.e., between 100Hz and 1 kHz. When the PWM
frequency is 1 kHz, the duty ratio will be 1/22727

From here:

analogWrite(pin, value) enables software PWM on the given pin. PWM may be used on pins 0 to 16. Call analogWrite(pin, 0) to disable PWM on the pin. value may be in range from 0 to PWMRANGE, which is equal to 1023 by default. PWM range may be changed by calling analogWriteRange(new_range).

PWM frequency is 1kHz by default. Call analogWriteFreq(new_frequency) to change the frequency.

So I think what you're meant to do is call analogWriteFreq(32768) to run at 32.768kHz.

Not sure exactly how accurate my oscilloscope is for Frequency measurement, but I found it in the ballpark but not particularly accurate. Also it had some glitches, so it's not precisely the same frequency every time. I suppose the ESP is occupied with other things sometimes. Fine for an LED or something but I wouldn't use it for anything critical.

Here they made it clear, check "Analog output" section. It's 40 KHz the maximum.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Khorne13 picture Khorne13  路  3Comments

mreschka picture mreschka  路  3Comments

SmartSouth picture SmartSouth  路  3Comments

tttapa picture tttapa  路  3Comments

Geend picture Geend  路  3Comments