Generating 12 MHz clock for external component

mhi32768
Posts: 3
Joined: Wed Jan 15, 2020 8:22 am

Generating 12 MHz clock for external component

Postby mhi32768 » Wed Jan 15, 2020 8:27 am

Hi,

is it possible to generate 12 MHz clock signal on some ESP32-WROOM32 pin (to be used as square clock for external component) ?
The duty resolution can be lowered down to 1 bit in which case the maximum frequency is 40 MHz, but only the duty of 50% is available
Which looks good, means that I can generate frequency up to 40 MHz, however 40MHz/12MHz = 3.33333 which is not a good divisor at all, in other words I need to change timer clock to something more useful for me (e.g. 48 MHz).

Or maybe can I use some other ESP32 peripheral such as SPI or I2S to generate continuous stream of data 000 111 000 etc ?

Thanks!

User avatar
rudi ;-)
Posts: 1731
Joined: Fri Nov 13, 2015 3:25 pm

Re: Generating 12 MHz clock for external component

Postby rudi ;-) » Wed Jan 15, 2020 1:44 pm

mhi32768 wrote:
Wed Jan 15, 2020 8:27 am
Hi,
is it possible to generate 12 MHz clock signal on some ESP32-WROOM32 pin (to be used as square clock for external component) ?

hi
one possible way is , you can try APLL to generate a constant clock on a pin. look at 3.2.7 Audio PLL (s. 42 ) in the TRM
clk_out.png
clk_out.png (48.76 KiB) Viewed 7929 times
you find more detailed things in the TRM ( technical reference manual ) of the ESP32, which is attached and you can get from espressif's documents share in en and in cn.

example play with registers or/and function

hope this helps for the start.

best wishes
rudi ;-)
Attachments
esp32_technical_reference_manual_en.pdf
V4.1 2019.11.21
(8.05 MiB) Downloaded 526 times
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1731
Joined: Fri Nov 13, 2015 3:25 pm

Re: Generating 12 MHz clock for external component

Postby rudi ;-) » Wed Jan 15, 2020 8:09 pm

also you can try this with little edit work to your wished 12MHz and other GPIO:
example how to generate 20MHz square wave at 50% duty on GPIO18.

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

mhi32768
Posts: 3
Joined: Wed Jan 15, 2020 8:22 am

Re: Generating 12 MHz clock for external component

Postby mhi32768 » Fri Jan 17, 2020 9:29 am

Thanks, which pin function is then used to output the 12 MHz clock signal to GPIO (TRM chapter 4.9 table ) ? For the first (ADC clk) solution. I am not very familiar with I2S..

About LEDC/PWM, I am not sure but I think frequency cannot be easily changed (base 80MHz) ? And 80 MHz is not very good for generating 12 MHz by single divisor.

mhi32768
Posts: 3
Joined: Wed Jan 15, 2020 8:22 am

Re: Generating 12 MHz clock for external component

Postby mhi32768 » Thu Feb 06, 2020 12:49 pm

Sorry for long time no try, I had another important work to do. I tried LEDC 12MHz clock generating approach an it works, somehow it can set the clock, BUT if I measure it on oscilloscope I get clock signal ranging from 11.4 to 13.3 MHz. This is unusable ...

User avatar
jgustavoam
Posts: 165
Joined: Thu Feb 01, 2018 2:43 pm
Location: Belo Horizonte , Brazil
Contact:

Re: Generating 12 MHz clock for external component

Postby jgustavoam » Sun Feb 09, 2020 12:48 pm

Maybe it can be useful.
Many resources in only small chip - awesome!

I2S0 Clock (master clock) up to 80MHz derived from APLL clock
viewtopic.php?f=18&t=14185
Retired IBM Brasil
Electronic hobbyist since 1976.

Who is online

Users browsing this forum: No registered users and 90 guests