Hi!
How to make ESP32 output 20MHZ's clock? And can you provide code?
How to make ESP32 output 20MHZ's clock
Re: How to make ESP32 output 20MHZ's clock
Do you mean you want a square wave output on a GPIO pin that has a frequency of 20MHz? If so, you can likely use the PWM functions.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: How to make ESP32 output 20MHZ's clock
OK ,Thank you,sorry for my bad English.I will check it
Re: How to make ESP32 output 20MHZ's clock
seems pwm can only be used to generate 333k clock ... what about higher frequencies ?
- ESP_krzychb
- Posts: 400
- Joined: Sat Oct 01, 2016 9:05 am
- Contact:
Re: How to make ESP32 output 20MHZ's clock
roctwo wrote:How to make ESP32 output 20MHZ's clock? And can you provide code?
Below is an example how to generate 20MHz square wave at 50% duty on GPIO18.
- #include "driver/ledc.h"
- ledc_timer_config_t ledc_timer = {
- .speed_mode = LEDC_HIGH_SPEED_MODE,
- .timer_num = LEDC_TIMER_0,
- .bit_num = 2,
- .freq_hz = 20000000
- };
- ledc_channel_config_t ledc_channel = {
- .channel = LEDC_CHANNEL_0,
- .gpio_num = 18,
- .speed_mode = LEDC_HIGH_SPEED_MODE,
- .timer_sel = LEDC_TIMER_0,
- .duty = 2
- };
- void app_main()
- {
- ledc_timer_config(&ledc_timer);
- ledc_channel_config(&ledc_channel);
- while (1) {
- ;
- }
- }
Who is online
Users browsing this forum: Bing [Bot], tahseenabbas52 and 75 guests