Output a clock signal in the MHz range

stefan
Posts: 3
Joined: Mon Aug 14, 2017 11:25 am

Output a clock signal in the MHz range

Postby stefan » Mon Aug 14, 2017 11:32 am

Hi guys!
How does one generate a stable clock signal above what the LED PWM provides?
I need a 2MHz square wave signal with 50:50 duty cycle.

Of cause the ESP32 is fast and I could use a RTOS thread, but there must be a more elegant way.

I see CLKout1, CLKout2, CLKout3 - #1 + #2 are on the USB pins - so what about CLKout3 (GPIO0)?
Or even better - because GPOI0 is connected to the boot sequence - have another pin do it - what about all those PWMs?

Any help would be awesome - I really don't feel like connecting a whole Arduino for the clock at this moment :-)

User avatar
iot-bits.com
Posts: 25
Joined: Wed Dec 21, 2016 6:14 am
Location: India
Contact:

Re: Output a clock signal in the MHz range

Postby iot-bits.com » Tue Aug 15, 2017 3:51 pm

You can use CLK_OUT pins to output any clock frequency (>= peripheral clock and accuracy subject to divisors). Check out the latest ESP32 TRM. It has details on how to output I2S clock on the CLK_OUT pins. It is really accurate.
- Pratik
:geek: Just another hobbyist and consultant

stefan
Posts: 3
Joined: Mon Aug 14, 2017 11:25 am

Re: Output a clock signal in the MHz range

Postby stefan » Tue Aug 15, 2017 10:31 pm

Ah OK, thanks for the hint!

To fill in others that have the same problem:
Using nothing but pin up/down in the main loop results in a short burst at about 1MHz on my scope.
Literally just

Code: Select all

setup: pinMode(5, OUTPUT);
loop:
GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 0b00000000000000000000000000100000);
GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 0b00000000000000000000000000100000);
So I will now try to activate I2S in Arduino. Haven't found anything Arduino specific till now...
Is there some "tutorial" on how to use those routines in the SDK and the ardu core - I am not the greatest when it comes to this sort of cross-everything-coding…

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Output a clock signal in the MHz range

Postby WiFive » Wed Aug 16, 2017 1:37 am


Who is online

Users browsing this forum: No registered users and 53 guests