single channel frequency generator

Posts: 1
Joined: Wed Jan 31, 2018 9:41 pm

single channel frequency generator

Postby ESP32Newb » Wed Jan 31, 2018 9:53 pm

Need to generate single channel output frequency between X Hz to Y MHz. No limitations on the waveform or duty cycle, so it can be a squarewave with 30% DC, for example, and I'll be very happy.

a. to have the widest range of X and Y.
b. Have the ability to change the output frequency at runtime


1. Can I have X be 1Hz?
2. Can I have Y be 1MHz?

What are some realistic numbers for X and Y using the least amount of code and/or using onboard peripherals?

I know that I can generate low frequency (X) by simply bitbanging a GPIO with the appropriate delay, but I would like to use hardware internal to the ESP32, like PWM/Timer

My concern is that, for X = 1Hz, the width of the timer register would be too small to count upto seconds and it would overflow multiples times because the clock rate is in nS on the ESP32 (is that correct?)

I can program using C/C++/Python, so language is not a problem for me

If I made any incorrect assumptions about the ESP32, please correct me

Posts: 1478
Joined: Tue Dec 01, 2015 8:37 am

Re: single channel frequency generator

Postby ESP_igrr » Thu Feb 01, 2018 4:14 am

LEDC peripheral can be used to generate PWM signals between 40 MHz (half of APB clock) and approximately 0.001 Hz.
Please check the LEDC chapter in Technical Reference Manual.
Here's a quick example which generates a ~1Hz signal. ... 47bee9850f

Posts: 13
Joined: Mon Sep 03, 2018 4:20 am

Re: single channel frequency generator

Postby ArtemN » Tue Feb 12, 2019 5:56 am

There is arduino examples for sub Hz PWM?

Who is online

Users browsing this forum: fly135, Google [Bot], joedonn, martinayotte and 21 guests