ESP output pin as clock input for IC
ESP output pin as clock input for IC
Hey,
I am wondering, is it possible to use an esp32's GPIO pin as a clock source for an external IC?
The IC needs a 4 MHz square signal. Can I use an esp32 hardware timer and do something like PWM for generating this clock signal?
What is the maximum frequency that can be realized?
Thank you!
Malte
I am wondering, is it possible to use an esp32's GPIO pin as a clock source for an external IC?
The IC needs a 4 MHz square signal. Can I use an esp32 hardware timer and do something like PWM for generating this clock signal?
What is the maximum frequency that can be realized?
Thank you!
Malte
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: ESP output pin as clock input for IC
Sure, take e.g. the LED PWM hardware and generate a PWM signal with a duty cycle of 50% and the desired frequency. I'm halfway sure you can generate signals up to 40MHz using that.
Re: ESP output pin as clock input for IC
Looking at section 6 of the ESP32 technical reference manual found here:
http://espressif.com/sites/default/file ... ual_en.pdf
It seems that the ESP32 has 16 independent channels of PWM output. The frequency seems to be rated by a complex formula that I'd need to sit down and think about for a long, long while however it does appear to be able to accommodate 4MHz.
There also appears to be high level drivers for this function so you don't have to "mess" with poking registers ... see:
http://esp-idf.readthedocs.io/en/latest ... /ledc.html
http://espressif.com/sites/default/file ... ual_en.pdf
It seems that the ESP32 has 16 independent channels of PWM output. The frequency seems to be rated by a complex formula that I'd need to sit down and think about for a long, long while however it does appear to be able to accommodate 4MHz.
There also appears to be high level drivers for this function so you don't have to "mess" with poking registers ... see:
http://esp-idf.readthedocs.io/en/latest ... /ledc.html
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: ESP output pin as clock input for IC
Great! Thanks for your assessment!
I will give it a try.
Best,
Malte
I will give it a try.
Best,
Malte
Re: ESP output pin as clock input for IC
Hello, I am trying to use PWM functionality from ESP32 to generate frequency of 113kHz with 50% duty cycle.
When I do this, with the minimum precision (10 Bits), I get div_param lower than 256 (yields 176). Even at such frequency, I cannot generate 50% duty cycle.
How were you able to produce clock cycle at 40MHz??
That would only make div_param smaller, which will provide error. (ledc.c line 181-197)
Please help.
Thanks a lot in advance.
When I do this, with the minimum precision (10 Bits), I get div_param lower than 256 (yields 176). Even at such frequency, I cannot generate 50% duty cycle.
How were you able to produce clock cycle at 40MHz??
That would only make div_param smaller, which will provide error. (ledc.c line 181-197)
Please help.
Thanks a lot in advance.
Re: ESP output pin as clock input for IC
Try with bit_num = 8
Re: ESP output pin as clock input for IC
I know, that with the lower bit number, it should be possible.
But when looking at the driver code https://github.com/espressif/esp-idf/bl ... ledc.h#L78, it seems that it should be at least 10 bits precise. Can I just alter the driver code and try with 8 or 9 bits?
Why is it then, that the enum is only from 10 to 15?
But when looking at the driver code https://github.com/espressif/esp-idf/bl ... ledc.h#L78, it seems that it should be at least 10 bits precise. Can I just alter the driver code and try with 8 or 9 bits?
Why is it then, that the enum is only from 10 to 15?
Last edited by seopyoon on Thu Feb 02, 2017 5:21 am, edited 2 times in total.
Re: ESP output pin as clock input for IC
Yes just use numeric value. Was able to generate 113.2khz.
Perhaps because those are the recommended range for working with LEDs?
https://github.com/igrr/esp32-cam-demo/ ... era.c#L100
Perhaps because those are the recommended range for working with LEDs?
https://github.com/igrr/esp32-cam-demo/ ... era.c#L100
Last edited by WiFive on Thu Feb 02, 2017 5:23 am, edited 1 time in total.
Re: ESP output pin as clock input for IC
To ensure, if I use 8 bits, i would set duty as 128 for having half the period on, and half the period off, right??? I ask this, since I do not have access to oscilloscope to make sure.
Re: ESP output pin as clock input for IC
Yes 2^8 / 2 = 128
Who is online
Users browsing this forum: Google [Bot], kaxx1975 and 364 guests