single channel frequency generator
Posted: 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.
Requirements:
a. to have the widest range of X and Y.
b. Have the ability to change the output frequency at runtime
Questions:
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
Requirements:
a. to have the widest range of X and Y.
b. Have the ability to change the output frequency at runtime
Questions:
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