could I to generate 40Mhz pulse on esp32 GPIO
-
- Posts: 9
- Joined: Thu Dec 06, 2018 4:20 am
could I to generate 40Mhz pulse on esp32 GPIO
I tried from those codes on Google but seem they doesn't work! Is the esp32 can do that?
best regards
NewPrasertKitt
best regards
NewPrasertKitt
Re: could I to generate 40Mhz pulse on esp32 GPIO
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
-
- Posts: 9
- Joined: Thu Dec 06, 2018 4:20 am
Re: could I to generate 40Mhz pulse on esp32 GPIO
Rudi, thanks for your kindly help. could you tell me how to code these in arduino.
best regards
NewPrasertKitt
best regards
NewPrasertKitt
Re: could I to generate 40Mhz pulse on esp32 GPIO
Which Board you want use?NewPrasertKitt wrote: ↑Fri Dec 07, 2018 12:10 pmRudi, thanks for your kindly help. could you tell me how to code these in arduino.
best regards
NewPrasertKitt
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
-
- Posts: 166
- Joined: Wed Aug 01, 2018 12:06 pm
Re: could I to generate 40Mhz pulse on esp32 GPIO
1 tick on a hardware timer is at 80Mhz. Divide that by two and send it to a GPIO pin. I'd use direct write to the GPIO pin instead of digitalwrite.
https://techtutorialsx.com/2017/10/07/e ... nterrupts/
https://techtutorialsx.com/2017/10/07/e ... nterrupts/
-
- Posts: 9
- Joined: Thu Dec 06, 2018 4:20 am
Re: could I to generate 40Mhz pulse on esp32 GPIO
Hello rudi,
I did try this sample code and reconfig the timer as below
timer = timerBegin(0, 2, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 2, true);
timerAlarmEnable(timer);
I use digitalWrite command to set and reset the GPIO but the pulse output just nothing. How to direct set/reset the GPIO, I think the digitalWrite command is too slow, not fast enough to work at this frequency.
I use Heltec Wifi Kit32 board.
Thanks
best regards
NewPrasertKitt
I did try this sample code and reconfig the timer as below
timer = timerBegin(0, 2, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 2, true);
timerAlarmEnable(timer);
I use digitalWrite command to set and reset the GPIO but the pulse output just nothing. How to direct set/reset the GPIO, I think the digitalWrite command is too slow, not fast enough to work at this frequency.
I use Heltec Wifi Kit32 board.
Thanks
best regards
NewPrasertKitt
-
- Posts: 9
- Joined: Thu Dec 06, 2018 4:20 am
Re: could I to generate 40Mhz pulse on esp32 GPIO
hello idahowalker,
could you show me how to code in arduino to direct write GPIO of ESP32. thank you.
best regards
NewPrasertKitt
could you show me how to code in arduino to direct write GPIO of ESP32. thank you.
best regards
NewPrasertKitt
- ESP_krzychb
- Posts: 400
- Joined: Sat Oct 01, 2016 9:05 am
- Contact:
Re: could I to generate 40Mhz pulse on esp32 GPIO
Hi NewPrasertKitt,
The simplest approach is to use on board peripherals to generate the pulse and do not engage the CPUs directly. In this case I propose LED Controller.
The simplest approach is to use on board peripherals to generate the pulse and do not engage the CPUs directly. In this case I propose LED Controller.
- #include "driver/ledc.h"
- #define PULSE_OUTPUT_PIN 4
- void setup()
- {
- ledc_timer_config_t ledc_timer;
- ledc_channel_config_t ledc_channel;
- ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE;
- ledc_timer.timer_num = LEDC_TIMER_0;
- ledc_timer.bit_num = (ledc_timer_bit_t) 1;
- ledc_timer.freq_hz = 40000000;
- ledc_channel.channel = LEDC_CHANNEL_0;
- ledc_channel.gpio_num = PULSE_OUTPUT_PIN;
- ledc_channel.speed_mode = LEDC_HIGH_SPEED_MODE;
- ledc_channel.timer_sel = LEDC_TIMER_0;
- ledc_channel.duty = 1;
- ledc_timer_config(&ledc_timer);
- ledc_channel_config(&ledc_channel);
- }
- void loop()
- {
- delay(1000);
- }
Last edited by ESP_krzychb on Sat Dec 15, 2018 4:03 pm, edited 1 time in total.
Re: could I to generate 40Mhz pulse on esp32 GPIO
a small complex arduino example taken from esp-idf
note:
so i think the rtc_plla_ena is now removed from the lib ..
the example by @krzychb is simple and good and do the things you searched for too.
also the timer example. what you want to do ?
best wishes
rudi
Code: Select all
#include "soc/emac_ex_reg.h"
extern void rtc_plla_ena(bool ena, uint32_t sdm0, uint32_t sdm1, uint32_t sdm2, uint32_t o_div);
// for rev0 chip: f_out = f_xtal * (sdm2 + 4) / (2 * (o_div + 2))
// so for 40MHz XTAL, sdm2 = 1 and o_div = 1 will give 50MHz output
void setup() {
// put your setup code here, to run once:
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO16_U, FUNC_GPIO16_EMAC_CLK_OUT);
REG_SET_FIELD(EMAC_EX_CLKOUT_CONF_REG, EMAC_EX_CLK_OUT_H_DIV_NUM, 0);
REG_SET_FIELD(EMAC_EX_CLKOUT_CONF_REG, EMAC_EX_CLK_OUT_DIV_NUM, 0);
REG_CLR_BIT(EMAC_EX_CLK_CTRL_REG, EMAC_EX_EXT_OSC_EN);
REG_SET_BIT(EMAC_EX_CLK_CTRL_REG, EMAC_EX_INT_OSC_EN);
// this did in the past 50Mhz enabled sig on GPIO
// since the rtc_plla_ena was removed from lib
// not sure how this can be enabled now
rtc_plla_ena(1, 0, 0, 1, 0);
}
void loop() {
// put your main code here, to run repeatedly:
}
note:
so i think the rtc_plla_ena is now removed from the lib ..
the example by @krzychb is simple and good and do the things you searched for too.
also the timer example. what you want to do ?
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
-
- Posts: 9
- Joined: Thu Dec 06, 2018 4:20 am
Re: could I to generate 40Mhz pulse on esp32 GPIO
rudi, krzychb thanks for your help, I use this pulse signal to test osciloscope bandwidth.
best regards
NewPrasertKitt
best regards
NewPrasertKitt
Who is online
Users browsing this forum: No registered users and 31 guests