ESP 32 is fa.........st - Page 1
Forum section: electronics / general

author: ebclr
author_rank: Super Contributor
timestamp: February 19, 2017, 02:31:31 pm
content: Quick reply without calculatingWhat will be signal frequency on output5, on a standard esp32 board using Arduino and espressifvoid loop() {// put your main code here, to run repeatedly:digitalWrite( 5,HIGH );// delay(100);digitalWrite( 5,LOW );// delay(100);}

author: cowana
author_rank: Frequent Contributor
timestamp: February 19, 2017, 02:48:19 pm
content: No idea!But if a 16MHz ATMEGA328 manages about 200kHz with the bloat of digitalWrite, I'd expect somewhere around 3MHz from an ESP32 running at 240MHz?

author: ebclr
author_rank: Super Contributor
timestamp: February 19, 2017, 02:50:00 pm
content: Amazing 3.65 Mhz

author: daybyter
author_rank: Frequent Contributor
timestamp: February 19, 2017, 09:50:08 pm
content: How fast is analogRead ?

author: Bruce Abbott
author_rank: Frequent Contributor
timestamp: February 20, 2017, 12:33:57 am
content: Quote from: cowana on February 19, 2017, 02:48:19 pmOr,withoutthe bloat...Code:.include "m328def.inc"ldi r16,1<<5out DDRB,r16loop:out PINB,R16rjmp loop2.67MHz (3.33MHz @20MHz)

author: sleemanj
author_rank: Super Contributor
timestamp: February 20, 2017, 01:40:29 am
content: It's no secret that the pin operations in the Arduino main core are very bloated and slow.Frustratingly it would be possible to refactor the functions (pinMode, digitalWrite, digitalRead...) a bit and use some GCC compile-time magic to make serious optimisation for constant (compile time known) arguments such that a digitalWrite or pinMode for example would be optimised down to a single sbi or cbi instruction,like I did for my ATTinyCore forkBut I think any such pull request on the main arduino core would probably languish in the pit of "oh but it might break [insert random thing that a developer happens to use] which was relying on the slowness".

author: pancio
author_rank: Contributor
timestamp: October 17, 2024, 11:14:56 am
content: Hi,I've question regarding max possible frequency on ESP32 Wemos D32 Pro module...I wrote very simple program (as a ESP-idf framework):Code:#include "driver/gpio.h"#define LED 5void app_main() {gpio_reset_pin(LED);gpio_set_direction(LED, GPIO_MODE_OUTPUT);while(1){gpio_set_level(LED, 1);gpio_set_level(LED, 0);}}and it's works perfect but so slow... I can't imagine that max frequency on GPIO is lower than 1.5MHz. The question is how to increase speed on GPIO?Best Regards,pancio

author: xvr
author_rank: Frequent Contributor
timestamp: October 17, 2024, 01:15:32 pm
content: QuoteWrite directly to IO registers. gpio_set_level is wrapper around that write (you can extract it source from ESP-IDF). And quite fat wrapper

author: wek
author_rank: Frequent Contributor
timestamp: October 17, 2024, 01:17:54 pm
content: Code:esp_err_t gpio_set_level(gpio_num_t gpio_num, uint32_t level){GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG);gpio_hal_set_level(gpio_context.gpio_hal, gpio_num, level);return ESP_OK;}-->#define gpio_hal_set_level(hal, gpio_num, level) gpio_ll_set_level((hal)->dev, gpio_num, level)-->__attribute__((always_inline))static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t level){if (level) {if (gpio_num < 32) {hw->out_w1ts = (1 << gpio_num);} else {HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1ts, data, (1 << (gpio_num - 32)));}} else {if (gpio_num < 32) {hw->out_w1tc = (1 << gpio_num);} else {HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1tc, data, (1 << (gpio_num - 32)));}}}Try to look at disasm to see into how many instructions does this compile.JW

author: agehall
author_rank: Frequent Contributor
timestamp: October 17, 2024, 03:07:08 pm
content: I mean, if you want fast, don’t use Arduino.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 17, 2024, 05:48:53 pm
content: Quote from: pancio on October 17, 2024, 11:14:56 amI'm not familiar with ESP32 and it's framework, but might it be that the core clock is low?This will also result in slow toggling of the IO.Your code does not show any setup of the hardware, so no way to know about if the speed is increase able or not.

author: nctnico
author_rank: Super Contributor
timestamp: October 17, 2024, 06:41:49 pm
content: There are quite a few layers of software between hardware and application layer. However, there is a hardware manual describing the registers so controlling the hardware registers directly is definitely possible and should increase speed considerably.

author: pancio
author_rank: Contributor
timestamp: October 18, 2024, 07:28:35 am
content: Thanks @All for answer.I thought that so short program which not using any additional layer e.g. FreeRTOS shall be compiled with some kind of optimization. Moreover - it was compiled under ESP-IDF delivered by ESP. I'm not familiar with Arduino, so I tried to do it as simply as possible. Ok, I'll try to do it directly using register as proposed by @wek :-)According HW and clock... I'm using WEMOS D32 PRO (LOLIN) module and I suppose it's working with default configuration - suppose it's 240MHz. I haven't any additional configuration in my project. I'm working on Linux, VSC and PlatformiO with newest libraries.

author: glenenglish
author_rank: Frequent Contributor
timestamp: October 18, 2024, 07:17:10 pm
content: As usual, an 8 MHz AVR can beat a ESP32 on toggle for all the reasons outlined above.ESP32 are a good option for those more familiar with high level machines , but is not suited to being a low level down and dirty better controller because of ll the abstraction.Beware, some of the GPIOs because of the way they are driven, are subject to glitches. That's in the tech manual, avoid those for specific uses....

author: tooki
author_rank: Super Contributor
timestamp: October 18, 2024, 07:52:45 pm
content: This is a mostly academic question, in that the ESP32 is known for not having fast GPIO toggling. But that’s because one isn’t supposed to rely on that for critical IO. The I2S/LCD interface, on the other hand, is intended for that, and supports much, much higher speeds.Edit: And just to be clear, while the I2C/LCD interface is called that, it can be used for anything. I’ve seen it used for driving LED video wall modules, for example.

author: pancio
author_rank: Contributor
timestamp: October 19, 2024, 11:04:36 am
content: Quote from: glenenglish on October 18, 2024, 07:17:10 pmI released mentioned by you reasons... normally I'm using smaller uCs like CH32V003 or if I need more GPIOs V307 version. I tried to use ESP32 just for PoC to be sure it's possible to use it with projects which needs more power. It's for future use.