Wrong delay when use "delay ms" ESP32

Any bugs you encounter with Flowcode should be discussed here.
flowjmaria
Posts: 10
http://meble-kuchenne.info.pl
Joined: Sat Dec 05, 2020 6:34 pm

Wrong delay when use "delay ms" ESP32

Post by flowjmaria »

Hello everyone, in a simple project with delay ms, when I only try to use delay between 1ms and 9ms the delay is wrong. However if I use delay us and delay s, no problem.

Only is for information of issue.

Thanks.

LeighM
Valued Contributor
Posts: 457
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 82 times
Been thanked: 246 times

Re: Wrong delay when use "delay ms" ESP32

Post by LeighM »

This is due to the fact that the delay_mS resolution is limited by the RTOS tick period.
(RTOS has some advantages, some disadvantages :D

delay_uS does not allow other tasks to run, it just consumes CPU cycles

flowjmaria
Posts: 10
Joined: Sat Dec 05, 2020 6:34 pm

Re: Wrong delay when use "delay ms" ESP32

Post by flowjmaria »

Please, look this picture, there you can see what happen with delay_ms wrong between 1ms and 9 ms.

Thanks.
Attachments
SIMPLY PROJECT DELAY FC9 ESP32
SIMPLY PROJECT DELAY FC9 ESP32
DELAYS FC9 ESP32.JPG (78.35 KiB) Viewed 13127 times

BenR
Matrix Staff
Posts: 1936
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 506 times
Been thanked: 688 times

Re: Wrong delay when use "delay ms" ESP32

Post by BenR »

Hello,

Many thanks for reporting this. Are millisecond delays of 10ms and over ok?

I'll see if there is an easy way for us to fix this in the code.

flowjmaria
Posts: 10
Joined: Sat Dec 05, 2020 6:34 pm

Re: Wrong delay when use "delay ms" ESP32

Post by flowjmaria »

Hello Ben, yes over 10ms the delay is OK.

Thanks.

BenR
Matrix Staff
Posts: 1936
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 506 times
Been thanked: 688 times

Re: Wrong delay when use "delay ms" ESP32

Post by BenR »

Aha thanks I've now made a change via the update system that hopefully will help.

Let us know how you get on.

flowjmaria
Posts: 10
Joined: Sat Dec 05, 2020 6:34 pm

Re: Wrong delay when use "delay ms" ESP32

Post by flowjmaria »

Hello Ben, Now it works OK.

Thanks a lot.

jgu1
Posts: 797
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 686 times
Been thanked: 177 times

Re: Wrong delay when use "delay ms" ESP32

Post by jgu1 »

Hi ben (hope it´s ok I ask now flowmaria?)

Seem that timing is ok now. But now I am even not possible to program the chip. And it´s the same program as first used.
Attachments
IliEsp).fcfx
(13 KiB) Downloaded 776 times
IliEsp).msg.txt
(4.29 KiB) Downloaded 750 times

jgu1
Posts: 797
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 686 times
Been thanked: 177 times

Re: Wrong delay when use "delay ms" ESP32

Post by jgu1 »

Me again!

I tryed to make a new project.............................. :D And yes, now Ili9341 work with ESP32 :D

I work, but when I compare the speed of update with other Arduino project, it´s a little low, but ok. I though the ESP32 processor is very fast.

But finally, succes. :D

Br jorgen

BenR
Matrix Staff
Posts: 1936
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 506 times
Been thanked: 688 times

Re: Wrong delay when use "delay ms" ESP32

Post by BenR »

Hi Jorgen,

Great news :D
I work, but when I compare the speed of update with other Arduino project, it´s a little low, but ok. I though the ESP32 processor is very fast.
The ESP processor is very fast but it seems the IO is not. I have done a bit of hacking away at the ESP IDF toolchain already to strip away some layers and this sped up the IO a fair bit but it's still a bit slow when compared to other MCUs.

Here is a similar topic on Espressif forums. We will keep looking for optimisations but it could be that raw IO bit toggling is just not very efficient on ESP devices.

https://www.esp32.com/viewtopic.php?t=1595

I have a plan to implement the RMT peripherals on the device which should allow for hardware driven fast comms. This will help to allow things like WS2812B and 1-Wire components to function but may also be useful for GLCDs. Hardware SPI might also be a good option.

Post Reply